[Lazarus] TStringList.LoadFromFile encoding parameter
Michael Van Canneyt
michael at freepascal.org
Sat Jul 9 18:16:51 CEST 2016
On Sat, 9 Jul 2016, Ondrej Pokorny wrote:
> 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.
OK.
So what is the encoding argument supposed to do ?
- Convert to current codepage (as set in
http://www.freepascal.org/docs-html/rtl/system/defaultsystemcodepage.html
) with possible loss of characters during read ?
- Keep all strings in the codepage that was passed on ?
>
> 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.
AFAIK It is Delphi compatible, and there it is unicodestring (well, widestring).
Michael.
More information about the Lazarus
mailing list