[fpc-pascal] TInifile does not handle " " (space) as a value.
Torsten Bonde Christiansen
tc at epidata.info
Fri Aug 4 09:09:18 CEST 2017
Dear List.
I was trying to use the ini file for our program to store a single space
" " as a value, but this does not seem to be posible.
From the Wikipedia definition of INI file
(https://en.wikipedia.org/wiki/INI_file#Whitespace) whitespace in values
does not seem to be well defined, so it may just be a design choice.
The following illustrates the issue:
program Project1;
{$mode objfpc}{$H+}
uses
Classes, IniFiles;
var
Ini: TIniFile;
S: String;
begin
Ini := TIniFile.Create('/tmp/test.ini');
Ini.WriteString('sec1', 'S', ' ');
Ini.Free;
Ini := TIniFile.Create('/tmp/test.ini');
S := Ini.ReadString('sec1', 'S', 'ZZ'); // S is '' and not ' ' as
expected
Ini.Free;
end.
Is this considered a bug or "by design"?
Kind regards
Torsten Bonde Christiansen
More information about the fpc-pascal
mailing list