[fpc-devel] TStrings and BOM

Bart bartjunk64 at gmail.com
Tue Dec 31 17:54:58 CET 2019


Would introducing a overload of TStrings.SaveTo* with a 3rd parameter
to controle the writing of the BOM be acceptable?

Reason: convenience:
Fpc 3.2 introduces 2 new behaviours of TStrings: Encoding and WriteBom.
For those of us who are used to have UTF8 encode textfile without BOM
(and want to keep it that way for whatever reason) we have to
incorporate 2 changes in our code:
- change calls to TSrings.LoadFrom*/SaveTo* to handle encoding issues
- change WriteBom to False before SaveTo*

SaveToStream(Fn, TEncoding.UTF8, False) is a one line change.
WriteBom := False;
SaveToStream(Fn, TEncoding.UTF8) is a two line change.

SaveTo*(Filename, TEncoding) would then call
SaveTo*(Filename, TEncoding, FWriteBom)

I know current method signatures are the same as Delphi, but nothing
stops us from being better that the Greek now, do they?


More information about the fpc-devel mailing list