I'm using ANSI escape codes ("\033[%d;%dH") to position Unicode
characters on a terminal window. The indices to provide for %d
are suited for (e.g.) the Latin character sets, but not for
character sets where characters require more than one unit for
the displayed glyph, e.g. like the Chinese characters. So with
a Latin character set I'd use indices 1, 2, 3, ... and for the
Asian sets I's use 1, 3, 5, ... to position the characters at
the screen. My question:
Is the size that the character glyphs need for representation
on a terminal somehow retrievable, so that I get, say, for
Unicode character \U0041 a value of 1 and for \U30ee a value
of 2, so that I can automatize the displaying on a terminal?
[ characters from different languages (or Unicode planes) require
differing amounts of cells for displaying in a terminal window ]
'wc -L' seems to be the solution for me; it's non-standard but works
on my system at least.
$ printf "\U30ee" | wc -L
2
$ printf "\U0041" | wc -L
1
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 223:37:31 |
Calls: | 6,623 |
Calls today: | 5 |
Files: | 12,171 |
Messages: | 5,318,368 |