[fpc-devel] TStrings and BOM
Michael Van Canneyt
michael at freepascal.org
Thu Jan 2 14:58:45 CET 2020
On Thu, 2 Jan 2020, Bart via fpc-devel wrote:
> 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.
That seems not compatible to me.
More information about the fpc-devel