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

Michael Van Canneyt michael at freepascal.org
Fri Apr 15 08:35:40 CEST 2016



On Thu, 14 Apr 2016, Michael Schnell wrote:

> On 04/14/2016 08:52 AM, Michael Van Canneyt wrote:
>> The default encoding for the string type is determined at run-time, not at 
>> compile time.
>> 
> How can that work for string constants ? Will they in fact (virtually) change 
> their encoding when DefaultSystemcodepage is different  ?

It depends.

>
> For a test I did   result := StringCodePage('äü');
>
> This results in a 0 which is CP_ACP, which is supposed to mean "in fact its 
> the value of DefaultSystemcodepage", which in my test in Linux is  65001 
> which means UTF8.

For string constants there are slightly different rules. There the result
depends on the {$codepage} directive of the source file.

See
http://wiki.freepascal.org/FPC_Unicode_support

>
> Of course in this test it's correct. But if I start the executable in a 
> system that imposes another value of DefaultSystemcodepage or if it is 
> compiled in a way that results in the constant strings to be coded in another 
> way than 65001, what will I see  ? (Right now I don't have a Lazarus 
> installation on Windows at hand).

Again, see
http://wiki.freepascal.org/FPC_Unicode_support

Michael.


More information about the fpc-pascal mailing list