utf8: split out unichar_console_width() from utf8_char_console_width()

It will be used later.
This commit is contained in:
Yu Watanabe
2026-07-23 14:40:37 +09:00
parent 8a5c8b751b
commit 5c0d4b5061
2 changed files with 7 additions and 0 deletions
+6
View File
@@ -179,10 +179,16 @@ int utf8_char_console_width(const char *str) {
char32_t c;
int r;
assert(str);
r = utf8_encoded_to_unichar(str, &c);
if (r < 0)
return r;
return unichar_console_width(c);
}
int unichar_console_width(char32_t c) {
if (c == '\t')
return 8; /* Assume a tab width of 8 */