[fpc-pascal] TIniFile.WriteString gives file with BOM, bad

Michael Van Canneyt michael at freepascal.org
Sat Jan 11 12:37:33 CET 2020



On Sat, 11 Jan 2020, Luca Olivetti wrote:

> El 11/1/20 a les 0:19, Michael Van Canneyt ha escrit:
>> 
>> 
>> On Fri, 10 Jan 2020, AlexeyT via fpc-pascal wrote:
>> 
>>>         ini_lexmap:= TIniFile.Create(fn_lexmap_final);
>>>         try
>>>           ini_lexmap.WriteString('ref', IntToStr(i_sub), s_lexer);
>>>         finally
>>>           FreeAndNil(ini_lexmap);
>>>         end;
>>>
>>> with FPC trunk it converts .ini file to UTF8 BOM! Bad, because then my 
>>> code reads this .ini file and it cannot find its 1st section: 
>>> BOMCHARS[ref] is not found, only [ref] is found in original file. So
>> 
>> I will disable the writing of BOM in TIniFile alltogether.
>
> With backward compatibility please (i.e. that after the writing has been 
> disabled TIniFile can still correctly read ini files that already have 
> the BOM).

Yes. The setting should only affect writing.

Michael.


More information about the fpc-pascal mailing list