[fpc-devel] Delphi incompatible encoding

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Dec 2 10:11:23 CET 2014


On Tue, 02 Dec 2014 04:05:59 +0100
Hans-Peter Diettrich <DrDiettrich1 at aol.com> wrote:

>[...]
> BTW it's nice that FPC console Write/Ln (mostly) converts AnsiStrings to 
> the console codepage, while Delphi (XE) doesn't convert :-)

+1

Although it confuses people who don't know about "console
codepage" (OEM codepage).

 
> But I found a somewhat strange result with generic String variables, 
> tested with:
> 
> var A: AnsiString; S: String;
> begin
>    S := ' äöü';
>    A := S;
>    //S := A; //changes nothing
>    WriteLn('A CP: ',StringCodePage(A), A); //always shows ' äöü'
>    WriteLn('S CP: ',StringCodePage(S), S); //letters differ
> end.

What codepage is the source file?

Many things affect string literals. Source codepage, system codepage,
string type, defaultsystemcodepage, library, compiler version.

I started a table for UTF-8 literals:
http://wiki.lazarus.freepascal.org/Character_and_string_types#String_constants


Mattias



More information about the fpc-devel mailing list