ElementTree and utf-16 encoding

  • Thread starter =?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=
  • Start date
?

=?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=

Hi,

ET being ElementTree in the following code, could anyone explain
why it fails ?
Traceback (most recent call last):
....
xml.parsers.expat.ExpatError: encoding specified in XML declaration is
incorrect: line 1, column 30

I s it related to the lack of BOM in the xml string ?
I tried to add some "\xff\xfe" or "\xfe\xff" at the start of the xml
string without much sucess with fromstring so far ...

Cheers,

SB
 
F

Fredrik Lundh

Sébastien Boisgérault said:
ET being ElementTree in the following code, could anyone explain
why it fails ?

I'm afraid the standard serializer in 1.2 only supports ASCII-compatible
encodings. this will be fixed in 1.3.

as a workaround, you can do:

tostring(elem).decode("utf-8").encode("utf-16")

</F>
 
?

=?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=

encodings. this will be fixed in 1.3.

as a workaround, you can do:

tostring(elem).decode("utf-8").encode("utf-16")

</F>

OK, thanks.

SB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top