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)

6 comments:

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

    ReplyDelete
  2. This Blog is very informative for us. Thanks for writing about it. In this article, some examples help me in applying in daily life. amazing You have explained each and everything very well in detail like I get help through do my assignment online. I hope you will write more pieces which help us in our daily routines.

    ReplyDelete
  3. We're endlessly sharing new markdown codes, https://www.certaxlondon.co.uk/, and sorts of progress, like free new turn of events. Limit scrambling toward Redeem Your Snapfish Coupon Code.

    ReplyDelete
  4. This blog is quite useful to us. Thank you for taking the time to write about it. Some examples in this post assist me in applying what I've learned in my daily life. amazing You have thoroughly described everything, just as I do when I seek assistance online dissertation help service service. I hope you will continue to create articles that will assist us in our daily lives.

    ReplyDelete
  5. my name is Albert Roy. We find this blog to be very helpful. We appreciate you spending the time to write about it. I can use some of the examples in this post to apply what I've learned to my everyday life. amazing You've explained everything in great detail, precisely as I do when I ask write my report for help. I hope you'll keep writing articles to help us with our daily life.

    ReplyDelete