[fpc-pascal] Re: UTF8 JSON library: was: [Lazarus] UTF-8 XML
Mattias Gaertner
nc-gaertnma at netcologne.de
Sun Jun 24 20:38:50 CEST 2012
On Sun, 24 Jun 2012 15:14:36 -0300
Luiz Americo Pereira Camara <luizmed at oi.com.br> wrote:
> Em 24/6/2012 12:22, Reinier Olislagers escreveu:
> > On 24-6-2012 17:05, Luiz Americo Pereira Camara wrote:
> >
> >> Hi,
> >>
> >> Thanks for your work. I plan to look at OAuth library soon
> > No problems, if you have questions, please feel free to ask.
>
> I will
>
> >
> >> 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
> > https://bitbucket.org/reiniero/fpctwit/src/efde73d5b1b3/fpjsonreadme.TXT
> > I applied your patch from bug 22197.
>
> I already read but got curious since that change was not supposed to
> handle this kind of situation
>
> > 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:
> > e.g.
> > from:
> > // Takes care of conversion...
> > S:=WideChar(StrToInt('$'+S));
> > to:
> > // Convert from Unicode codepoint in hex to UTF8... via UTF16:
> > S:=Utf8Encode(WideString(WideChar(StrToInt('$'+S))));
or more direct:
using lazutf8:
S:=UnicodeToUTF8(StrToInt('$'+S));
Mattias
More information about the fpc-pascal
mailing list