Steven Bethard steven.bethard at
Mon Sep 3 04:40:35 CEST 2007

Sönmez Kartal wrote:
> I was using the XMLBuilder( I'm writing XML files as
> "f.write(str(xml))". At execution of that line, it gives error with
> description, configure your default encoding...
[and later]
> I get this when it happens: "Decoding Error: You must configure
> default encoding" which comes from in the code excerpt in
> (

Can you show the code where you populate the XMLBuilder? I'm guessing 
you're doing something like::

     import xmlbuilder
     builder = xmlbuilder.XMLBuilder() = dict(bar='® and ™')

That breaks because the string '® and ™' is not properly encoded. Have 
you declared an encoding in your source file? PEP 263 shows you how:

Note that with Python 2.5 the code above gives a SyntaxError without a 
proper encoding. You should also probably be prefixing your string 
literals containing weird characters with "u" to make them unicode. 
Doing both of these in the code above made it work for me.


More information about the Python-list mailing list