[fpc-devel] TStrings and BOM
lazarus at kluug.net
Thu Jan 2 01:06:56 CET 2020
On 02.01.2020 0:51, Ondrej Pokorny wrote:
> On 01.01.2020 23:59, Werner Pamler wrote:
>> Am 01.01.2020 um 17:01 schrieb Ondrej Pokorny:
>>> Isn't the TStrings.WriteBOM property good enough? Why to have yet
>>> another not-very-useful overload?
>> To be honest I think Bart's idea of making the BOM an optional
>> parameter of the Save methods appears to me more efficient than
>> defining a property just for this only purpose. Do we really have to
>> imitate all the nonsense dictated by Delphi?
> I see it's quite popular to humble every new Delphi feature after
> Delphi 7 as being nonsense. Not every time the criticism is valid. And
> never it is a good argument.
> The WriteBOM property has a valid purpose - it is set in LoadFrom*
> according to the BOM presence in the loaded file. I.e. if you do:
> MyStrings.LoadFromFile('abc'); // WriteBOM and Encoding properties are
> set here
> MyStrings.SaveToFile('abc'); // they are used here to save the file as
> it was loaded
> The abc file keeps BOM and encoding of the original one. You cannot
> achieve it with the AWriteBOM parameter Bart suggested.
I stand corrected. Neither FPC nor Lazarus do it. Obviously my memory
doesn't serve me well and I didn't check it before sending the email.
Only the encoding is set, not the WriteBOM property.
But still adding an overload just to omit one line for changing some
property is nonsense. You can do so in a class helper if you want.
More information about the fpc-devel