[Tutor] why is unichr(sys.maxunicode) blank?

Albert-Jan Roskam fomcl at yahoo.com
Sat May 18 12:39:22 CEST 2013



----- Original Message -----

> From: eryksun <eryksun at gmail.com>
> To: tutor at python.org
> Cc: 
> Sent: Saturday, May 18, 2013 5:28 AM
> Subject: Re: [Tutor] why is unichr(sys.maxunicode) blank?
> 
> On Fri, May 17, 2013 at 11:06 PM, Dave Angel <davea at davea.name> wrote:
>>  One tool that can help is the name function in module unicodedata
>> 
>>   >>> import unicodedata
>>   >>> unicodedata.name(u'\xb0')
>>  'DEGREE SIGN'
>> 
>>  If you try that on the values near sys.maxunicode you get an exception:
>>  ValueError: no such name
> 
> There's no name since the code point isn't assigned, but the category
> is defined:
> 
>     >>> unicodedata.category(u'\U0010FFFD')
>     'Co'
>     >>> unicodedata.category(u'\U0010FFFE')
>     'Cn'
>     >>> unicodedata.category(u'\U0010FFFF')
>     'Cn'
> 
> 'Co' is the private use category, and 'Cn' is for codes that 
> aren't assigned.

Thank you. That unicodedata module is very handy sometimes (and crucial for regexes, sometimes). I rarely use it but I should have remembered it.



More information about the Tutor mailing list