C++ 检查unicode字符是否为全角 [英] C++ check if unicode character is full width
问题描述
如何检查一个 unicode 字符是否为全角?
How to check if a unicode character is full width?
我使用 Win32/MFC
I use Win32 / MFC
例如中
是全宽,A
不是全宽,F
是全宽,F
> 不是全宽.
For example, 中
is full width, A
is not full width, F
is full width, F
is not full width.
推荐答案
您需要的是检索东亚宽度 字符.您可以通过解析 Unicode 字符数据库中的 EastAsianWidth.txt 文件来实现.我找不到返回此信息的 Win32 API,但在 Python 中,例如,您可以使用 unicodedata.east_asian_width(unichr)
.
What you need is to retrieve the East Asian Width of the character. You can do it by parsing the EastAsianWidth.txt file from the Unicode Character Database. I could not find a Win32 API that returns this info, but in Python, for example, you can use unicodedata.east_asian_width(unichr)
.
有关问题的背景和更多信息,请参阅附件 #11.
See the Annex #11 for the background of the problem and more information.
这篇关于C++ 检查unicode字符是否为全角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!