[fpc-pascal] Re: UTF8 JSON library: was: [Lazarus] UTF-8 XML

Reinier Olislagers reinierolislagers at gmail.com
Sun Jun 24 17:22:08 CEST 2012

On 24-6-2012 17:05, Luiz Americo Pereira Camara wrote:
> Em 24/6/2012 07:58, Reinier Olislagers escreveu:
>> Related:
>> With the help of Ludo Brands - as usual ;) - I've converted the FPC
>> fpjson library to return UTF8 data.
>> I use it for my twitter/Oauthv1 library/program; you can find it
>> incorporated there at
>> https://bitbucket.org/reiniero/fpctwit/src
>> See e.g. fpjsonreadme.TXT
>> I've renamed the units so they shouldn't conflict with the FPC ones.
>> Note: I've only had to convert JSON strings to objects, not the other
>> way round; haven't tested that.
>> No idea whether the RTTI stuff works, haven't used it.
>> As usual, comments/patches welcome ;)
> Hi,
> Thanks for your work. I plan to look at OAuth library soon
No problems, if you have questions, please feel free to ask.

> About fpjson and UTF8, can you post an example showing the problem?
The symptom is that the tweets, which are UTF8, get converted to my ANSI
codepage on Windows. This means e.g. Greek or Japanese tweets can't be
displayed or stored correctly.

As mentioned in
I applied your patch from bug 22197.

Then, adapted line jsonscannerutf8.pp line 244 (FPC 2.7.1 jsonscanner.pp
line 238/239), function DoFetchToken
to convert incoming json string data to UTF8 instead of system codepage:
// Takes care of conversion...
// Convert from Unicode codepoint in hex to UTF8... via UTF16:
> Maybe i can help.
It's working for me right now ;) Just wanted to note that I haven't
tested converting objects to JSON output, just JSON strings to objects.

Of course, if you have improvement suggestions, they're very welcome.

> Are you using fpc 2.7.1?
I'm using 2.6.1 - however I forked the UTF8 fpjson code from the trunk
r21678 version as described in the readme.


More information about the fpc-pascal mailing list