Re: xml.dom.minidom character encoding

2010-04-21 Thread Stefan Behnel
C. Benson Manica, 21.04.2010 19:19: I have the following simple script running on 2.5.2 on a machine where the default character encoding is "ascii": #!/usr/bin/env python #coding: utf-8 import xml.dom.minidom import codecs str=u"" doc=xml.dom.minidom.parseString( str ) xml=doc.toxml( encoding

Re: xml.dom.minidom character encoding

2010-04-21 Thread Peter Otten
C. Benson Manica wrote: > On Apr 21, 2:25 pm, Peter Otten <__pete...@web.de> wrote: > >> Are you sure that your script has >> >> str = u"..." >> >> like in your post and not just >> >> str = "..." > > No :-) > > str=u" \"ó\"/>" > doc=xml.dom.minidom.parseString( str.encode("utf-8") ) > xml=doc.

Re: xml.dom.minidom character encoding

2010-04-21 Thread C. Benson Manica
On Apr 21, 2:25 pm, Peter Otten <__pete...@web.de> wrote: > Are you sure that your script has > > str = u"..." > > like in your post and not just > > str = "..." No :-) str=u"" doc=xml.dom.minidom.parseString( str.encode("utf-8") ) xml=doc.toxml( encoding="utf-8") file=codecs.open( "foo.xml", "w

Re: xml.dom.minidom character encoding

2010-04-21 Thread Peter Otten
C. Benson Manica wrote: > On Apr 21, 1:58 pm, Peter Otten <__pete...@web.de> wrote: >> C. Benson Manica wrote: >>> (snip) >> >> It seems that parseString() doesn't like unicode > > Yes, I noticed that, and I already tried... > >> -- let's try a byte string >> then: >> >> >>> doc = xml.dom.minido

Re: xml.dom.minidom character encoding

2010-04-21 Thread C. Benson Manica
On Apr 21, 1:58 pm, Peter Otten <__pete...@web.de> wrote: > C. Benson Manica wrote: >> (snip) > > It seems that parseString() doesn't like unicode Yes, I noticed that, and I already tried... > -- let's try a byte string > then: > > >>> doc = xml.dom.minidom.parseString(s.encode("utf-8")) > >>> xm

Re: xml.dom.minidom character encoding

2010-04-21 Thread Peter Otten
C. Benson Manica wrote: > I have the following simple script running on 2.5.2 on a machine where > the default character encoding is "ascii": > > #!/usr/bin/env python > #coding: utf-8 > > import xml.dom.minidom > import codecs > > str=u" \"ó\"/>" > doc=xml.dom.minidom.parseString( str ) > xml=

xml.dom.minidom character encoding

2010-04-21 Thread C. Benson Manica
I have the following simple script running on 2.5.2 on a machine where the default character encoding is "ascii": #!/usr/bin/env python #coding: utf-8 import xml.dom.minidom import codecs str=u"" doc=xml.dom.minidom.parseString( str ) xml=doc.toxml( encoding="utf-8" ) file=codecs.open( "foo.xml"