目前 Python 還不能直接處理 Extension-b 以上的5碼 Unicode.
如果讀入的檔案中含有 5碼 Unicode, surrogate paris 會被當做2個 Unicode 字元.
需要自行做一些處理.
下面這個程式片段可以取代 ord() 用來傳回 unicode(包含4碼或5碼) 的 code point:
def codePoint(s):if len(s)==1: return ord(s)
high=ord(s[0]) if high<0xd800 or high>0xdbff: return highhigh=high & 0x3ff
high+=0x40 high = high << 10 low=ord(s[1]) low=low& 0x3ff return high + low2011.3.30