tReplace character with U+FFFD if wcwidth() is -1 - st - [fork] customized buil… | |
git clone git://src.adamsgaard.dk/st | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 11625c7166b7e4dad414606227acec2de1c36464 | |
parent 008aae541b5cb1e67a025048adef9a06eaa11c2e | |
Author: [email protected] <[email protected]> | |
Date: Tue, 28 Oct 2014 12:55:28 +0100 | |
Replace character with U+FFFD if wcwidth() is -1 | |
Helpful when new Unicode codepoints are not recognized by libc. | |
Diffstat: | |
M st.c | 5 ++++- | |
1 file changed, 4 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/st.c b/st.c | |
t@@ -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; | |
} |