[Lazarus] Making sources compatible with Delphi (but Lazarus is priority)

Florian Klaempfl florian at freepascal.org
Sun May 7 10:42:36 CEST 2017


Am 07.05.2017 um 10:30 schrieb Mattias Gaertner via Lazarus:
> On Sun, 7 May 2017 10:10:26 +0200
> Florian Klaempfl via Lazarus <lazarus at lists.lazarus-ide.org> wrote:
> 
>> Am 05.05.2017 um 13:35 schrieb Graeme Geldenhuys via Lazarus:
>>> On 2017-05-05 12:17, Mattias Gaertner via Lazarus wrote:  
>>>> I wonder if it would help if FPC would store UTF-8 string literals as
>>>> UTF-8   
>>>
>>> Yeah, that would be the logical thing to do.   
>>
>> Why? What makes a string literal UTF-8?
> 
> Here: $codepage utf-8 and non ASCII.
> 
> 
>>> FPC not doing that is what
>>> really confused me.  
>>
>> You have to distinuish between source encoding and string encoding.
> 
> Yes, but sometimes the string encoding is not obvious:
> 
> {$codepage utf8}
> const s = 'äöüالعَرَبِيَّة';
> begin
>   writeln(s); // needs widestringmanager
> end.

Yes. Which is good imo. The compiler should call the unicode writeln in
this case and this requires a widestringmanager (where I agree, its name
is chosen wrong, it should be named unicodestringmanager) anyways. If
the string were encoded UTF-8 and the ansistring writeln is called, your
example would work only on a system with an utf-8 console. But you can
achieve the same (broken output) by just leaving away the codepage
directive then. It will not work on non utf-8 consoles either.



More information about the Lazarus mailing list