Unicode
文章目录
工具
unicodedata 模块
- python 官方模块, unicode 字符集处理工具
unicodeit 模块
生成 unicode 字符的网站
命令行 terminal 输出宽度
希腊字母声调符号
unicode 转 ascii (信息可能丢失)
unicode table 字符查询网站:
希腊字母变形,如 varphi, varepsilon 等
特殊字符
合并字符
教程
- wiki 资料汇总: Category:Unicode - Wikipedia
- 一个 python unicode 使用介绍,类似 cookbook
encode, decode, 错误处理
1 2 3 4 5 6 7 8 9 10 11 12 13 14>> u = b"\xff" u.decode('utf-8', 'strict') Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte # use U+FFFD, REPLACEMENT CHARACTER >> u.decode('utf-8', "replace") '\ufffd' # inserts a \xNN escape sequence >> u.decode('utf-8', "backslashreplace") '\xff' # leave the character out of the Unicode result >> u.decode('utf-8', "ignore") ''
- Python Unicode HowTo: Unicode HOWTO — Python 3.11.1 documentation
添加声调 accent 等 combing character (合并字符)
参考:
- Combining character - Wikipedia
- python - How do I add accents to a letter? - Stack Overflow
- 变音符号:Combining Diacritical Marks - Unicode Character Table
解说:
- 手动合并字符
不同的合并字符组合可能无效,或者达不到预期效果的奇怪符号
- 比如 "1" 上面加横线字符,变成:
1̅
- 比如 "1" 上面加横线字符,变成:
| |
文章作者
上次更新 2024-01-05 (5c92d1c)