chars: measure invalid sequences and unassigned codepoints more quickly

Invalid multibyte sequences get depicted with the Replacement Character,
and unassigned codepoints are shown as if they were a space.  Both have
a width of one.
master
Benno Schulenberg 2016-06-05 21:42:27 +02:00
parent 91fff2a2c8
commit 8686cb3d3d
1 changed files with 3 additions and 5 deletions

View File

@ -280,15 +280,13 @@ int mbwidth(const char *c)
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc_reset();
wc = bad_wchar;
return 1;
}
width = wcwidth(wc);
if (width == -1) {
wc = bad_wchar;
width = wcwidth(wc);
}
if (width == -1)
return 1;
return width;
} else