[fpc-pascal] FPC 3 regression: cannot use TStringList for UTF-8 data any more?

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Apr 16 11:02:46 CEST 2016


On Fri, 15 Apr 2016 10:43:55 +0200
Michael Schnell <mschnell at lumino.de> wrote:

>[...]
> Do you suggest that the codepage of the sourcecode is preserved by the 
> compiler when creating the string constant in object code  ?

It depends.
There are two codepages. The real one and the one you tell the
compiler.
If you tell the compiler that the string literal is 8-bit system
codepage, it will copy it without conversion to the binary.
Otherwise it converts it to UTF-16.

For instance using {$codepage utf8} tells the compiler to convert all
your literals to UTF-16.

Without the {$codepage} the compiler preserves the real codepage.

> Seemingly StringCodePage does not work correctly with string constants 
> anyway: I found that setting {$codepage UTF8}, for a constant string I 
> get StringCodePage = 1200 which is UTF16.

StringCodePage on a literal is pretty useless. You should
use StringCodePage on variables.

Mattias



More information about the fpc-pascal mailing list