[fpc-pascal] Re: RE : JSON and UTF8

Reinier Olislagers reinierolislagers at gmail.com
Wed Jul 11 07:36:34 CEST 2012


On 11-7-2012 4:19, waldo kitty wrote:
> On 7/10/2012 07:00, Luiz Americo Pereira Camara wrote:
>> With the old behavior, in an system with a system code page <> UTF8,
>> if i try to
>> show the parsed value of "\u4E01" in e.g. a LCL app will get garbage.
>>
>> I would expect to work correctly in any enviroment
> 
> this means that some environments will end up with "garbage" for those
> UTF-8 characters that cannot be translated back to the local codepage...

And your point is?
This change moves the conversion problem from with the JSON library to
your responsibility. Please note that these same characters in a JSON
string would have ended up as garbage already in the old situation.

In the new situation, you have some more control over it. If you don't
like the new behaviour, you can always set the conversion flag in the
constructor to false instead of its default true... and move back to the
earlier "conversion in a black box" method.

However, if you don't have a need to convert to system codepage, as you
say, you could lose information because the conversion is lossy.
That has been fixed (and correctly so, IMO).
For instance, I can now get a UTF8 JSON string, and write it out to a
UTF8 File, process it with the FPC UTF8 functions, show it in a Lazarus
TEdit or grid, etc.

Thanks,
Reinier










More information about the fpc-pascal mailing list