utf8: let utf8_console_width() handle NULL strings somewhat reasonably
This commit is contained in:
committed by
Luca Boccassi
parent
78fb0ca46d
commit
bba55185de
+4
-1
@@ -597,11 +597,14 @@ size_t utf8_n_codepoints(const char *str) {
|
||||
}
|
||||
|
||||
size_t utf8_console_width(const char *str) {
|
||||
size_t n = 0;
|
||||
|
||||
if (isempty(str))
|
||||
return 0;
|
||||
|
||||
/* Returns the approximate width a string will take on screen when printed on a character cell
|
||||
* terminal/console. */
|
||||
|
||||
size_t n = 0;
|
||||
while (*str) {
|
||||
int w;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user