[fpc-devel] TStrings and BOM
bartjunk64 at gmail.com
Thu Jan 2 12:38:41 CET 2020
On Thu, Jan 2, 2020 at 12:12 PM Michael Van Canneyt
<michael at freepascal.org> wrote:
> In Delphi it doesn't matter where the encoding comes from.
> If writeBOM is true and there is a preamble for the encoding (whatever it
> is), it is used.
I think I have to rephrase my question.
In fpc TStrings.SaveToStream(AStream) does NOT use DefaultEncoding if
Encoding is nil.
So this code:
//Source codepage is Windows 1512
SL := TStringList.Create;
SL.SkipLastLineBreak := True;
SL.WriteBOM := True;
SL.DefaultEncoding := TEncoding.UTF8;
S := 'ä'; // = #$0E
Will result in St having as content 1 single byte: 0E (hex)
SL.SaveToStream(St, nil) will result in St having a content of 5
bytes: EF BB BF C3 A4
Is that Delphi compatible?
>From the help text of the Embarcadero site I cannot figure that out.
More information about the fpc-devel