Displaying Unicode Chars
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Sun Feb 10 23:32:22 CET 2008
gregpinero at gmail.com wrote:
> However how can I change it so it works with a string variable?
> print unicode("\u221E") doesn't seem to do it.
Sure, that's because \u only works in unicode strings. You'd need
to "encode" your \u-containing string to a unicode string. Perhaps
>>> def to_unicode(num):
... character = "\\u"+num
... return character.decode("unicode-escape")
>>> print to_unicode("221E")
BOFH excuse #273:
The cord jumped over and hit the power switch.
More information about the Python-list