[fpc-devel] TStrings and BOM
Michael Van Canneyt
michael at freepascal.org
Thu Jan 2 12:12:46 CET 2020
On Thu, 2 Jan 2020, Bart via fpc-devel wrote:
> On Wed, Jan 1, 2020 at 1:00 PM Bart <bartjunk64 at gmail.com> wrote:
> Meanwhile, can anybody who has a recent Delphi version comment on this:
>> B.t.w. Am I correct in understanding that when TStrings.SaveTo*()
>> without an encoding parameter (so, the 1 parameter version) will NOT
>> write the BOM if Encoding = nil, whereas the SaveTo* with Encoding
>> parameter will write the BOM if Encoding is nil?
>> (Assuming that WriteBom=True and DefaultEncoding.GetPreamble returns
>> something with Length > 0)
> Is this indeed the case in Delphi?
> That would mean that if Strings.Encoding is nil and
> TStrings.DefaultEncoding is TEncoding.UTF8 then SaveToFile(Fn) would
> give a different result then SaveToFile(Fn, TEncoding.Utf8).
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.
More information about the fpc-devel