a simple unicode question

Terry Reedy tjreedy at udel.edu
Wed Oct 21 23:56:49 CEST 2009

Nobody wrote:

>> Just curious, why did you choose to set the upper boundary at 0xffff?
> Characters outside the 16-bit range aren't supported on all builds. They
> won't be supported on most Windows builds, as Windows uses 16-bit Unicode
> extensively:
> 	Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
> 	win32
> 	>>> unichr(0x10000)
> 	Traceback (most recent call last):
> 	  File "<stdin>", line 1, in <module>
> 	ValueError: unichr() arg not in range(0x10000) (narrow Python build)

In Python 3, if not 2.6, chr(0x10000) (what used to be unichr()) works 
fine on Windows, and generates the appropriate surrogate pair.

More information about the Python-list mailing list