[XML-SIG] encoding problem with DOM Writing

kevin Thackray kevin.thackray at clarisys.fr
Fri May 7 06:28:39 EDT 2004


hi everyone,

I have an encoding problem when I am writing DOM document "from scratch".
By the way, thank you Mr Andrew Clover for that help with wrinting dom 
from scratch, i got my DOM wrapper working :) !
I am using 4DOM, and PyPgSql for extracting datas from PostGres.
I create my new document throught the interface :
newDoc = implementation.createDocument(None, "DOC", None)
Also, I am dealing with french datas so in the database there are some 
iso-88-59-1 characters.
Then i add somes nodes, and when i want to print that out with 
PrettyPrint, it raise this error :
(PrettyPrint(newDoc, encoding="iso-8859-1"))

UnicodeDecodeError: 'utf8' codec can't decode bytes in position 37-38: 
unexpected end of data

When i try to encode database incomming datas with this function :
def _encode(v):
        v = v.encode("iso-8859-1")
    return v

This raise that exception :

    v = v.encode("iso-8859-1")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 37: 
ordinal not in range(128)

I think my problem is that I don't handle the encoding while writing the 
new document, but i found no way to specify that with the 
creatDocument() interface.
If anyone have any ideas or clues that you help me!!

Regards,

Kevin Thackray.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kevin.thackray.vcf
Type: text/x-vcard
Size: 70 bytes
Desc: not available
Url : http://mail.python.org/pipermail/xml-sig/attachments/20040507/aa3f9f40/kevin.thackray.vcf


More information about the XML-SIG mailing list