[fpc-pascal] What is the size of AnsiChar

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Nov 5 12:55:41 CET 2012


On 05 Nov 2012, at 11:49, ik wrote:

> As I understand, AnsiString and AnsiChar contain the environment type
> of string (it can be ISO8859x, utf-8 etc...).
> If that so, how can I know the size (in bytes) of AnsiChar ?

The size of the type "AnsiChar" is always one byte. It is impossible  
to give the size of a generic "character" in a 1-byte string, because  
in e.g. UTF-8 the size depends on the code point. To get the size of a  
specific character, you can use
   widestringmanager.codepointlengthproc(pchar,maxlookahead)

"maxlookahead" is the maximum number of bytes that routine is allowed  
to check to find the complete character (e.g.  
"widestringmanager 
.codepointlengthproc(@ansistringvar[3],length(ansistringvar)-2)"). It  
seems this routine has not yet been implemented for the Windows  
widestringmanager though.


Jonas



More information about the fpc-pascal mailing list