[Twisted-Python] Encoding patch for twisted.web.microdom.Document
Francisco Miguel Colaço
fcolaco at demnet.ubi.pt
Sun Aug 17 12:36:28 EDT 2003
I have patched that class, in order to make the xml opening as:
<?xml version="1.0" encoding="utf-8" ?>
One may choose the encoding by passing the encoding="my-encoding" as
an additional argument to Document.
This is the only way I have for the site I do (in continental
portuguese, if that matters) in Galeon and Mozilla.
Here is the diff (I have renamed the original microdom.py to
microdom-old.py in order to test the server.
< def __init__(self, documentElement=None):
> def __init__(self, documentElement=None, encoding='utf-8'):
> ## Add a default encoding.
> self.encoding = encoding
< stream.write('<?xml version="1.0"?>' + newl)
> stream.write('<?xml version="1.0" encoding="' + self.encoding
+ '" ?>' + newl)
Maybe the same thing dould be applied in xmlrpc.py, since the <?xml?>
string is also hardwired. Is this patch useful?
More information about the Twisted-Python