C ++ checks to see if Unicode character is full width

How to check if a Unicode character is full width?

I am using Win32 / MFC

For example, δΈ­ is full width, A not full width, οΌ¦ is full width, F is not full width.

+7
c ++ visual-c ++ winapi unicode mfc
source share
2 answers

You need to get the East Asian character width . You can do this by analyzing the EastAsianWidth.txt file from the Unicode character database. I could not find the Win32 API that returns this information, but for example in Python you can use unicodedata.east_asian_width(unichr) .

See Appendix No. 11 for the background of the problem and additional information.

+8
source share

What do you mean by "full width"? The width of the character depends on the font on which it is displayed.

If you mean whether this is a single byte character or not, it is still not clear. One byte character in which encoding? In UTF-8, it will have one byte character if (and only if) the code point is less than 128; if you use UTF-16 (probably because you are on Windows), just compare the character with 128. Single-byte encoding in ISO 8859-1 (another widespread encoding): compare with 256. For anything less than 256, the unit is UTF- 16 will be numerically identical to the code point in ISO 8859-1 (sometimes known as Latin-1). For one byte, ASCII encoding (almost never used today, but most common encodings are identical with it for the first code is 128 points) is something less than 128.

-2
source share

All Articles