Question concerning Unicode and or Shift-JIS

Neil Hodgson nhodgson at bigpond.net.au
Fri Mar 12 03:54:11 EST 2004


Antioch:

> however the problem is I don't know how to "decode" the UTF and then
> recode it into Shift-JIS so that I can compare the dictionary values with
> the input values.

   I don't have a Shift-JIS codec installed so this breaks but should work
if you have the codec installed:

y = '\xe3\x81\x8b\xe3\x82\x8f\xe3\x81\x95\xe3\x81\x8d'
print y
print repr(y)
u = unicode(y, "utf-8")
print repr(u)
s = u.encode("shift-jis")
print s

   Neil





More information about the Python-list mailing list