utf8: let utf8_console_width() handle NULL strings somewhat reasonably

This commit is contained in:
Lennart Poettering
2024-06-15 00:46:42 +01:00
committed by Luca Boccassi
parent 78fb0ca46d
commit bba55185de
+4 -1
View File
@@ -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;