码位(code position/point)Unicode 编码与 Python 2/3 编码兼容性问题

Unicode HOWTO
html

0. 码位(code position/point)

一个码位由某个数值表示,所有码位共同构成其码值空间(code space)。python

  • ASCII,0~7Fhex(128)
  • 拓展 ASCII,0~FFhex(256)
  • Unicode,0~10FFFFhex
    • 1, 114, 112,17×216(17 个平面

2. python 下的编码

  • bytes.decode() str.encode()

3. UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0x9c

好比在读取 œ 时,便会形成 UnicodeDecodeError。bash

>> b'\x9c'.decode('cp1252')
'œ'
相关文章
相关标签/搜索