fpTOML
fpTOML copied to clipboard
Float number and date parsing may fail in different countries
Problem: The float number and date parsing may fail in other countries, that is: where a system locale is set that is not English.
The reason for that is that you use the StrToFloat variant without the TFormatSettings parameter (two locations in TOMLParser.pas). This variant uses the system locale which may or may not match the TOML specification.
Solution: change these two code locations to use the StrToFloat variant that takes a second parameter of type TFormatSettings and specify settings that you created explicitly, e.g. by calling TFormatSettings.Create('en-US').
The simplest and most effective solution:
TToken.RealNumber:
begin
SScanf(pattern, '%f', [@f]);
result := TTOMLNumber.Create(f, TTOMLNumberType.Float);
Consume;
end;