Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-06

UTF-8 XML

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

I am using xmlread and dom from FPC to read a XML file and I got an unpleasant surprise.

It is converting things like this:

<mo>&#x00B1;<!-- &PlusMinus; --></mo>

Into:

<mo>?</mo>

But encoded in ISO 8859-1 which is awful as I don't want my program to go into the dark ages of pre-unicode and all problems it has.

I know that we have a XML reading library in Lazarus which uses UTF-8, but can it be utilized as a direct replacement for xmlread and dom?

To write my code I utilized this wiki page which I wrote most of a long time ago (back then I wasn't using non-ASCII so didn't notice this issue): http://wiki.freepascal.org/XML_Tutorial

Hopefully the Lazarus XML routines will be very similar...

Looking at our package LazUtils I found laz2_xmlread and laz_xmlread, so I suppose I should just go for the version with 2 on it, correct?

thanks,

Felipe Monteiro de Carvalho

Reply by email

Reinier Olislagers
to Felipe Monteiro de Carvalho: I am using xmlread and dom from FPC to read a XML file and I got an unpleasant surprise.…

(Cross-posted to Lazarus and FPC lists)

On the Lazarus list,

Felipe Monteiro de Carvalho wrote 17 lines
Hello, I am using xmlread and dom from FPC to read a XML file and I got an unpleasant surprise. It is converting things like this: <mo>&#x00B1;<!-- &PlusMinus; --></mo> Into: <mo>?</mo> But encoded in ISO 8859-1 which is awful as I don't want my program to go into the dark ages of pre-unicode and all problems it has. I know that we have a XML reading library in Lazarus which uses UTF-8,

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 ;)

Thanks,
Reinier

Reply by email

Mattias Gaertner
to Felipe Monteiro de Carvalho: I am using xmlread and dom from FPC to read a XML file and I got an unpleasant surprise.…
Show quoted text 15 lines
Hello, I am using xmlread and dom from FPC to read a XML file and I got an unpleasant surprise. It is converting things like this: <mo>&#x00B1;<!-- &PlusMinus; --></mo> Into: <mo>?</mo> But encoded in ISO 8859-1 which is awful as I don't want my program to go into the dark ages of pre-unicode and all problems it has.

The fpc units uses widestrings and support unicode. Do you mean the XML is encoded in ISO-8859-1 or that the read strings are?

Show quoted text 11 lines
I know that we have a XML reading library in Lazarus which uses UTF-8, but can it be utilized as a direct replacement for xmlread and dom? To write my code I utilized this wiki page which I wrote most of a long time ago (back then I wasn't using non-ASCII so didn't notice this issue): http://wiki.freepascal.org/XML_Tutorial Hopefully the Lazarus XML routines will be very similar... Looking at our package LazUtils I found laz2_xmlread and laz_xmlread, so I suppose I should just go for the version with 2 on it, correct?

The laz2_* are a simple port of the fpc units from widestrings to UTF-8. Plus a few small additions.

Mattias

Reply by email