Sign in Join

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

Mailing lists / fpc-pascal / 2006-10

FPC 2.0.2 vs 2.0.4 xmlread

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Alexander Todorov

Hello list,
I had an old application that worked fine with 2.0.2 but doesn't work with 2.0.4.
The problem is that it reads XML and then uses the data to do some processing. Application expects XML to be UTF-8 which is later converted to CP1251 in some cases.

I an sending an example program including the xmlread.pp units from 2.0.2 and 2.0.4 versions.
2.0.2 produces correct result. The xml attribute value printed is in cyrillic (Bulgarian). It is printed on the console in two different ways, the second one contains only ? characters.

Can you tell me is this a bug in xmlread or my code is wrong?

Second thing that I noticed:
The compiler gives error when calling ReadXMLFile prefixed with the unit name.

Thanks!
Alexander.

Michael Van Canneyt
to Alexander Todorov
Alexander Todorov wrote 6 lines
Hello list, I had an old application that worked fine with 2.0.2 but doesn't work with 2.0.4. The problem is that it reads XML and then uses the data to do some processing. Application expects XML to be UTF-8 which is later converted to CP1251 in some cases.

XML is not in UTF-8.

The XML unit is now XML 1.1 compliant. It performs conversion by itself, part of this change was indeed performed during the 2.0.4 release.

My guess is that you simply don't need to do any conversion yourself.

Michael.

Michael Van Canneyt
to Michael Van Canneyt
Michael Van Canneyt wrote 17 lines
On Tue, 24 Oct 2006, Alexander Todorov wrote: > Hello list, > I had an old application that worked fine with 2.0.2 but doesn't work > with 2.0.4. > The problem is that it reads XML and then uses the data to do some > processing. Application expects XML to be UTF-8 which is later > converted to CP1251 in some cases. XML is not in UTF-8. The XML unit is now XML 1.1 compliant. It performs conversion by itself, part of this change was indeed performed during the 2.0.4 release. My guess is that you simply don't need to do any conversion yourself.

Forgot to say: More information can be asked from the implementor: Sergei Gorelkin

Michael.

Alexander Todorov
Michael Van Canneyt wrote
XML is not in UTF-8.

What do you mean by that? I don't understand. If you delete the <?xml ... ?> line and save in a text file the "file" command says: UTF-8 Unicode text, if opened with web browser (e.g. Firefox) encoding is also shown as UTF-8. Opening the file with mcview in hex mode I saw latin characters are encoded with 1 byte and cyrillic with 2. I manually checked the values of these bytes against a reference table. This is also the result returned from (Ch and $1F) shl 6 + (Ch2 and $3F) in function InternalGetChar. After assigning the value to FCurChar ? appear.

        FCurChar := WideChar((Ch and $1F) shl 6 + (Ch2 and $3F));
The XML unit is now XML 1.1 compliant. It performs conversion by itself, part of this change was indeed performed during the 2.0.4 release.
  { supported encodings }
  TEncoding = (enUnknown, enUTF8, enUTF16BE, enUTF16LE);

Does CP1251 work?

My guess is that you simply don't need to do any conversion yourself.

I was doing UTF-8 to CP1251 conversion, but no the input I expected to be UTF-8 doesn't look nice to me. :)

I am going to test tomorrow with different text encodings and see what will happen.