Replace character with U+FFFD if wcwidth() is -1

Helpful when new Unicode codepoints are not recognized by libc.
This commit is contained in:
czarkoff@gmail.com 2014-10-28 12:55:28 +01:00 committed by Roberto E. Vargas Caballero
parent 008aae541b
commit 11625c7166

5
st.c
View file

@ -2576,7 +2576,10 @@ tputc(char *c, int len) {
unicodep = ascii = *c;
} else {
utf8decode(c, &unicodep, UTF_SIZ);
width = wcwidth(unicodep);
if ((width = wcwidth(unicodep)) == -1) {
c = "\357\277\275"; /* UTF_INVALID */
width = 1;
}
control = ISCONTROLC1(unicodep);
ascii = unicodep;
}