如何将 fancy/artistic unicode 文本转换为 ASCII?
How to convert fancy/artistic unicode text to ASCII?
我有一个像“”这样的 unicode 字符串,我想将它转换成 ASCII 形式的“thug life”。
我知道我可以通过
在Python中实现这个
import unidecode
print(unidecode.unidecode(' '))
// thug life
但是,这也会使我想保留的其他 unicode 字符(例如 Chinese/Japanese 字符、表情符号、重音字符等)变得不可见。
有没有办法检测这些类型的“艺术”unicode 字符?
更多示例:
thuj fe
感谢您的帮助!
import unicodedata
strings = [
' ',
' ',
' ',
' ',
'thug life']
for x in strings:
print(unicodedata.normalize( 'NFKC', x), x)
输出:.803325.py
thug life
thug life
thug life
thug life
thug life thug life
资源:
unicodedata
— Unicode Database
- Normalization forms for Unicode text
我有一个像“”这样的 unicode 字符串,我想将它转换成 ASCII 形式的“thug life”。
我知道我可以通过
在Python中实现这个import unidecode
print(unidecode.unidecode(' '))
// thug life
但是,这也会使我想保留的其他 unicode 字符(例如 Chinese/Japanese 字符、表情符号、重音字符等)变得不可见。
有没有办法检测这些类型的“艺术”unicode 字符?
更多示例:
thuj fe
感谢您的帮助!
import unicodedata
strings = [
' ',
' ',
' ',
' ',
'thug life']
for x in strings:
print(unicodedata.normalize( 'NFKC', x), x)
输出:.803325.py
thug life thug life thug life thug life thug life thug life
资源:
unicodedata
— Unicode Database- Normalization forms for Unicode text