[fpc-devel] Trying to understand the wiki-Page "FPC Unicode support"

Michael Schnell mschnell at lumino.de
Wed Nov 26 16:19:32 CET 2014

On 11/26/2014 03:05 PM, Sven Barth wrote:
> >
> > OK. So in Delphi XE (in Germany) String(CP_ACP) is the same as 
> String(CP1252) but different from String without brackets which in 
> turn is the same as String(CP_UTF16) ? Correct ?
> There is no "String with brackets". You can only use "AnsiString" 
> followed by brackets, not "String". And "String" in Delphi 2009+ is 
> the same as UnicodeString which is a different compiler internal type 
> than AnsiString(CP_UTF16) would be if it would be allowed.
> While both AnsiString and UnicodeString have the current codepage and 
> the character size in their header record the code page is only used 
> for AnsiString and the size can not he influenced in any way (for an 
> AnsiString it's always 1 and for a UnicodeString it's always 2).
So what is the notation in Delphi (and hence supposedly in FPC with 
"mode delphiunicode") to define a variable with the (static) string 
encoding type "CPXXXX" with XXX = 1252, UTF8, UTF16 ?
I found this:
   CP_ACP     = 0;     // default to ANSI code page
   CP_UTF16   = 1200;  // utf-16
   CP_UTF16BE = 1201;  // unicodeFFFE
   CP_UTF7    = 65000; // utf-7
   CP_UTF8    = 65001; // utf-8
   CP_ASCII   = 20127; // us-ascii
   CP_NONE    = $FFFF; // rawbytestring encoding

So seemingly you could do MyStringType       = type 
AnsiString(CP_UTF16), and seemingly the size information is set 
according to this.

> There is no UTF-32 string (at least not in the sense of a compiler 
> provided type).
I see (It's a shame).

Thanks a lot for your patience,

More information about the fpc-devel mailing list