[fpc-pascal] TJSONboolean and locale settings

Michael Van Canneyt michael at freepascal.org
Fri May 13 16:05:50 CEST 2016



On Fri, 13 May 2016, Graeme Geldenhuys wrote:

> Hi,
>
> Is TJSONboolean, and it’s internal BoolToStr(AValue, True) and
> StrToBool() calls, affected by locale settings?

GetAsString is.

>
> For example:
> My locale is en_GB and I store a Boolean (True) value to a JSON file,
> which results in a string value “True”. If I now read that JSON file on
> a system with locale af_ZA (Afrikaans, or any other non-English language
> for that matter) - would it still work?

Yes, because 'GetAsJSON' is not dependent on locale, but returns hardcoded
values.

function TJSONBoolean.GetAsJSON: TJSONStringType;
begin
   If FValue then
     Result:='true'
   else
     Result:='false';
end;


Michael.


More information about the fpc-pascal mailing list