正如标题所说。$ ./configure --help | grep -i ucs --enable-unicode[=ucs[24]]搜索官方文档后,我发现:sys.maxunicode:一个整数,为Unicode字符提供最大的支持代码点。此值取决于配置选项,该选项指定将Unicode字符存储为UCS-2还是UCS-4。此处不清楚的是-哪些值对应于UCS-2和UCS-4。该代码有望在Python 2.6+上运行。
3 回答

幕布斯6054654
TA贡献1876条经验 获得超7个赞
使用--enable-unicode = ucs4构建时:
>>> import sys
>>> print sys.maxunicode
1114111
使用--enable-unicode = ucs2构建时:
>>> import sys
>>> print sys.maxunicode
65535

慕丝7291255
TA贡献1859条经验 获得超6个赞
对于UCS-2,它是0xFFFF(或65535),对于UCS-4是0x10FFFF(或1114111):
Py_UNICODE
PyUnicode_GetMax(void)
{
#ifdef Py_UNICODE_WIDE
return 0x10FFFF;
#else
/* This is actually an illegal character, so it should
not be passed to unichr. */
return 0xFFFF;
#endif
}
UCS-4模式下的最大字符由UTF-16中可表示的最大值定义。
添加回答
举报
0/150
提交
取消