unichr() question

E

Ezequiel, Justin

(Also posted to tutor list 55 hours ago)

PythonWin 2.2.2
Windows XP
Traceback (most recent call last):
.... print ord(c)
....
55349
56490
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.
 
M

Martin v. =?iso-8859-15?q?L=F6wis?=

Ezequiel said:
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?

I strongly advise that you don't. Even though an UCS-2 Python build
has some capbilities to represent non-BMP characters, you should use
these facilities only if you know what you are doing, and if you
absolutely need it.

To convert UCS-4 into a pair of two UTF-16 codepoints, use
.... hi,lo=divmod(codepoint-0x10000,0x400)
.... return 0xd800+hi,0xdc00+lo
....(55349L, 56490L)


Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top