I am writing a terminal (console) application that should wrap arbitrary text in Unicode.
Terminals usually use a font of monospaced (fixed width), so for wrapping text it is just more than counting characters and viewing whether a word is on the line or not and acts accordingly.
The problem is that there are full width characters in the Unicode table that occupy 2 characters wide in the terminal.
Count that they will see one Unicode character, but the printed character has a width of 2 "normal" (half-width), violating the wrapping procedure, because it does not know characters that are twice as wide.
As an example, this is a full-width character (U + 3004, JIS character)
ã
12
Here it does not occupy the entire width of 2 characters, although it is pre-formatted, but it uses the double width of the western character in the terminal.
To deal with this, I have to distinguish between full-width or half-width characters, but I cannot find a way to do this in C ++. Do I really need to know all the full width characters in a Unicode table to get around the problem?
Noice source share