Unicode character not in range when calling locale.strxfrm
问题 I am experiencing an odd behavior when using the locale library with unicode input. Below is a minimum working example: >>> x = '\U0010fefd' >>> ord(x) 1113853 >>> ord('\U0010fefd') == 0X10fefd True >>> ord(x) <= 0X10ffff True >>> import locale >>> locale.strxfrm(x) '\U0010fefd' >>> locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') 'en_US.UTF-8' >>> locale.strxfrm(x) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: character U+110000 is not in range [U+0000; U