Re: [fpc-pascal] TIniFile.WriteString gives file with BOM, bad
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. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TIniFile.WriteString gives file with BOM, bad
On Fri, Jan 10, 2020 at 11:30 PM AlexeyT via fpc-pascal wrote: > Can you add TIniFile.WriteBom property? it's not quite enough, I need to > disable it globally in entire app (I have ~10 ini objects), so > additional global default is needed (like Lazarus has global variables). Open a ticket in the bugtracker? -- Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TIniFile.WriteString gives file with BOM, bad
Can you add TIniFile.WriteBom property? it's not quite enough, I need to disable it globally in entire app (I have ~10 ini objects), so additional global default is needed (like Lazarus has global variables). -- Regards, Alexey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TIniFile.WriteString gives file with BOM, bad
>> 2) if BOM is there, allow ReadString to find section at the file begin: I can read/write IniFiles with BOM with fpc r43847, with and withoud DefautSystemCodePage := CP_UTF8. Sorry, my mistake-- TIniFile can read this BOM file, but my software cannot: a) I've fixed one place where my app reads ini files via TextFile. b) I canNOT fix another place where PYTHON library reads ini file (Python has module for ini files). c) So yes, I want to disable BOM writing at all. -- Regards, Alexey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TIniFile.WriteString gives file with BOM, bad
On Fri, Jan 10, 2020 at 5:57 PM AlexeyT via fpc-pascal wrote: > 1) don't write BOM via WriteString It doesn't AFAICS. The BOM is written in UpdateFile. > 2) if BOM is there, allow ReadString to find section at the file begin: > BOMCHARS[ref] I can read/write IniFiles with BOM with fpc r43847, with and withoud DefautSystemCodePage := CP_UTF8. TIniFile might benefit from a WriteBom (Boolean) property ? -- Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TIniFile.WriteString gives file with BOM, bad
TIniFile manually adds the BOM to the first Line. Then SaveToFile is called, which (if FEncoding = Utf8) will add the BOM again? Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] TIniFile.WriteString gives file with BOM, bad
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 1) don't write BOM via WriteString 2) if BOM is there, allow ReadString to find section at the file begin: BOMCHARS[ref] fpc 3.3 r43852 linux x64. -- Regards, Alexey ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal