[Lazarus] TStringList.LoadFromFile encoding parameter

Ondrej Pokorny lazarus at kluug.net
Sat Jul 9 18:04:07 CEST 2016


On 09.07.2016 12:32, Michael Van Canneyt wrote:
> If the characters in the file encoding cannot be preserved in the current
> encoding for 'ansistring', then what ?

Is there even something like "current encoding for 'ansistring'" in FPC 
3.0? AFAIK FPC 3.0 AnsiString can handle all encodings and convert 
between them internally. By default TEncoding output could be set to 
AnsiString(CP_UTF8). Conversion to other codepages of AnsiString is done 
by the compiler.

I see now that FPC's TEncoding uses UnicodeString and PUnicodeChar. For 
me it's a strange decision. I would expect it to be String ( 
http://wiki.freepascal.org/Character_and_string_types#String ) and use 
UTF8 since AnsiString(CP_UTF8) is compatible to String.

Ondrej




More information about the Lazarus mailing list