unichr() question

Ezequiel, Justin j.ezequiel at spitech.com
Thu Oct 16 05:57:57 EDT 2003


(Also posted to tutor list 55 hours ago)

PythonWin 2.2.2
Windows XP

>>> long('1D4AA', 16)
119978L
>>> unichr(long('1D4AA', 16))
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
ValueError: unichr() arg not in range(0x10000) (narrow Python build)
>>> x = eval("u'\\U000%s'" % '1D4AA')
>>> x
u'\U0001d4aa'
>>> for c in x:
... 	print ord(c)
... 
55349
56490
>>> unichr(55349) + unichr(56490)
u'\U0001d4aa'
>>> 

How do I convert strings such as '1D4AA' to unicode without using eval()?
Alternatively, how can I break down the value 119978L into 55349 and 56490?

Please send a copy of your reply directly to me.






More information about the Python-list mailing list