utf8: split out unichar_console_width() from utf8_char_console_width()
It will be used later.
This commit is contained in:
@@ -179,10 +179,16 @@ int utf8_char_console_width(const char *str) {
|
|||||||
char32_t c;
|
char32_t c;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
assert(str);
|
||||||
|
|
||||||
r = utf8_encoded_to_unichar(str, &c);
|
r = utf8_encoded_to_unichar(str, &c);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
return unichar_console_width(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
int unichar_console_width(char32_t c) {
|
||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
return 8; /* Assume a tab width of 8 */
|
return 8; /* Assume a tab width of 8 */
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ static inline char32_t utf16_surrogate_pair_to_unichar(char16_t lead, char16_t t
|
|||||||
|
|
||||||
size_t utf8_n_codepoints(const char *str) _pure_;
|
size_t utf8_n_codepoints(const char *str) _pure_;
|
||||||
int utf8_char_console_width(const char *str) _pure_;
|
int utf8_char_console_width(const char *str) _pure_;
|
||||||
|
int unichar_console_width(char32_t c) _pure_;
|
||||||
size_t utf8_console_width(const char *str) _pure_;
|
size_t utf8_console_width(const char *str) _pure_;
|
||||||
|
|
||||||
size_t utf8_last_length(const char *s, size_t n) _pure_;
|
size_t utf8_last_length(const char *s, size_t n) _pure_;
|
||||||
|
|||||||
Reference in New Issue
Block a user