[fpc-devel] Delphi incompatible encoding

Hans-Peter Diettrich DrDiettrich1 at aol.com
Mon Dec 1 10:32:53 CET 2014

Now I could compile FPC 2.7.1 and perform some tests :-)
Unfortunately I couldn't submit an bug report, so it comes here:

When compiled with Delphi XE, the code below shows 1252 (my 
DefaultSystemCodePage) for all strings, be empty or non-empty.

Compiled with FPC 2.7.1, the StringCodePage(r) is reported as zero after 
the first assignment (r := s;).
This is incompatible with Delphi :-(

program rawtest;
   s: AnsiString; //UTF8String;
   r: RawByteString;
   s := 'abc';
   r := s;
   WriteLn('s CP: ',StringCodePage(s)); //1252
   WriteLn('r CP: ',StringCodePage(r)); //XE: 1252, FPC: 0
   s := r;
   WriteLn('s CP: ',StringCodePage(s)); //XE: 1252, FPC: 0

This difference may be due to an error in StringCodePage, more probably 
in RawByteString handling in general.

Another one:
Delphi XE does not export the CP_xxx encoding constants from System.pas. 
This means that the encoding constants are not available in (compatible) 
user code.
CP_NONE is declared in Windows.pas for clipping, as:
   CP_NONE      = 0;     { No clipping of output             }
different from the CP_NONE encoding ($FFFF).


More information about the fpc-devel mailing list