Thursday, March 17, 2016

unicode + ord

The ord() built-in may return very large values when handed a 1-character unicode string:

>>> ord(u'\U00008000')
32768


This means that chr(ord(s)) will not always work.

>>> chr(ord(u'\U00008000'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: chr() arg not in range(256)

3 comments:

  1. That's why there is also unichr() in the standard library.

    ReplyDelete
  2. Cracks.live
    Download latest cracks of mac & pc softwares. You can get full versions of latest games, softwares, applications and many tools.
    https://cracks.live

    ReplyDelete
  3. Softofree
    Get your favorite mac & windows applications on your computer or macbook. Free games & applications are available here to download Advanced SystemCare Crack With License Key

    ReplyDelete