encoding problem

Luis Zarrabeitia kyrie at uh.cu
Fri May 16 16:31:39 EDT 2008


Hi, guys.
I'm trying to read an xml file and output some of the nodes. For that, I'm 
doing a 
print node.toprettyxml()

However, I get this exception:

===
    out.write(tag.toxml())
UnicodeEncodeError: 'ascii' codec can't encode character u'\xba' in position 
190: ordinal not in range(128)
===

That happens if I "print" it, or send it to stdout, or send it to a file.

How can I fix it? 
cat file works perfectly, and I'm using an utf8 terminal.

I'm particularly puzzled that it won't work even if I write to a file opened 
in "b" mode. Worst thing is... I don't really need that character, just a 
general idea of how the document looks like.

-- 
Luis Zarrabeitia (aka Kyrie)
Fac. de Matemática y Computación, UH.
http://profesores.matcom.uh.cu/~kyrie



More information about the Python-list mailing list