[XML-SIG] cgi unicode encoding problem

James King mail at jameskingexpress.co.uk
Tue Mar 22 00:22:30 CET 2005


I am trying to convert CGI data, which arrives encoded with escape 
characters, into unicode data.

t represents the type of character data that I start with (the result 
of fetching cgi-field data from a cgi.FieldStorage object).

 >>> t = '\x93quotation marks\x94, and a series of other characters: 
\x91\xe5 \xdf \xa9 \xe6 \xee \x9c\x92'
 >>> import codecs
 >>> t.encode('utf-8')

Traceback (most recent call last):
   File "<stdin>", line 1, in ?
UnicodeError: ASCII decoding error: ordinal not in range(128)

I've tried using all sorts of other intermediary codecs, but I just 
haven't managed to get useful unicode out the other end.

Any help greatly appreciated.


James King

More information about the XML-SIG mailing list