[fpc-devel] new string - question on usage

Sven Barth pascaldragon at googlemail.com
Tue Oct 11 09:59:07 CEST 2011


Am 11.10.2011 08:11, schrieb Hans-Peter Diettrich:
> Jonas Maebe schrieb:
>> On 10 Oct 2011, at 22:11, Luiz Americo Pereira Camara wrote:
>>
>>> 1- Most of LCL must be code page agnostic, so not use
>>> UTF8String/AnsiString directly (keep String)
>>
>> There is no difference between ansistring and string in {$mode
>> delphi} and {$mode objfpc}.
>
> You obviously missed that the new AnsiString type has an encoding, with
> implicit conversions when strings of different codepages are passed to
> subroutines or stored in variables. An AnsiString on one machine may
> have a different encoding on a machine with a different user locale.
> When a string contains UTF-8, its encoding must be set to UTF-8 as well,
> otherwise implicit conversions will result in garbage - as observed by
> the OP.
>

Nevertheless Jonas' statement is correct, because (currently) String = 
AnsiString and thus they are the same (and both can currently use code 
pages).

Regards,
Sven



More information about the fpc-devel mailing list