Re: UnicodeDecodeError
Adam Todd <[email protected]>
| Newsgroups | gmane.mail.spam.tmda.user |
|---|---|
| Message-ID | <[email protected]> |
# Mark it and use the fallback
else:
# 20061118-at ref tmda-users list
# return "(%s) %s" % (CharSet,
# TranslateToUTF8(PVars[("General", "CSEncoding")], Str, Errors))
return TranslateToUTF8(PVars[("General", "CSEncoding")],
"(%s) %s" % (CharSet, unicode(Str, "latin1")), Errors)
Decoder = Lib.Codec().decode
except ImportError:
OK, did that.
And the first Pending page came up fine. But going to the next one:
/common/app/tmda-cgi-0.15/Unicode.py in
TranslateToUTF8(CharSet=u'iso-2022-jp',
Str='\x96\x88\x93\xfa\x82\xbd\x82\xa2\x82\xad\x82\xc2\x82\xc8\x82\xcc\x82\xc5',
Errors='ignore')
112 except ImportError:
113 # We know what it was, but we don't have the library installed.
114 return "(%s) %s" % (CharSet, Str)
115
116 # Decode string to Unicode
CharSet = u'iso-2022-jp', Str =
'\x96\x88\x93\xfa\x82\xbd\x82\xa2\x82\xad\x82\xc2\x82\xc8\x82\xcc\x82\xc5'
UnicodeDecodeError: 'ascii' codec can't decode byte 0x96 in position 0:
ordinal not in range(128)
args = ('ascii',
'\x96\x88\x93\xfa\x82\xbd\x82\xa2\x82\xad\x82\xc2\x82\xc8\x82\xcc\x82\xc5',
0, 1, 'ordinal not in range(128)')
encoding = 'ascii'
end = 1
object =
'\x96\x88\x93\xfa\x82\xbd\x82\xa2\x82\xad\x82\xc2\x82\xc8\x82\xcc\x82\xc5'
reason = 'ordinal not in range(128)'
start = 0
I still reckon "ditch it!" /dev/null is a nice place, I'm hardly going to
be able to read it anyway! (Yes, again I'm evil!)
At 12:11 AM 18/11/2006, Jim Ramsay wrote:
>Werner Fleck <[email protected]> wrote:
> > I might have found a fix for the problem, but be aware that this is my
> > first try at programming python :-)
> >
> > The error seems to be caused by the string operation in the line
> >
> > return "(%s) %s" % (CharSet,
> > TranslateToUTF8(PVars[("General", "CSEncoding")], Str, Errors))
> >
> > When I replace this with
> >
> > return TranslateToUTF8(PVars[("General", "CSEncoding")],
> > "(%s) %s" % (CharSet, unicode(Str, "latin1")),
> > Errors)
> >
> > everything works fine for me.
> >
> > I've attached a diff to this message.
>
>Great, and thanks for this! Adam, could you please try this patch and
>let me know if it fixes things for you? If so, I'll check it in to CVS
>right away.
>
>--
>Jim Ramsay
>"Me fail English? That's unpossible!"
>
>_____________________________________________
>tmda-users mailing list ([email protected])
>http://tmda.net/lists/listinfo/tmda-users