minidom and unicode errors
abhimanyu.seth at gmail.com
Tue Mar 7 08:32:52 CET 2006
On 3/7/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Abhimanyu Seth wrote:
> > Sorry, my mistake. The file was not saved as utf-8. Saving it as utf-8
> > solves my problems.
> > >> f = codecs.open ("c:/test.txt", "r", "utf-8")
> > >> dom = minidom.parseString (codecs.encode (f.read(), "utf-8"))
> > However, I still need to encode the string returned by f.read () before
> > passing it to parseString. Otherwise I get an exception.
> if the file contains UTF-8 data,
> dom = minidom.parse("c:/test.txt")
> should be exactly equivalent to your recoding solution. if it isn't, post
> copy of the sample file.
> (if you've double-checked, and are 100% certain that it's not your editor
> or your environment that's playing tricks with you, you can also report
> over here:
Hey thanks! yup, minidom.parse() works just fine.
But for writexml(), I still need to use codecs.open("c:/test.txt", "w",
"utf-8"). Is this a bug in writexml() ?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list