[fpc-devel] TStrings and BOM

Michael Van Canneyt michael at freepascal.org
Tue Dec 31 18:37:36 CET 2019



On Tue, 31 Dec 2019, Bart via fpc-devel wrote:

> Hi,
>
> 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.
> Whereas:
> 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?

By all means, patches welcome.

Michael.


More information about the fpc-devel mailing list