[hackers] [st] Replace character with U+FFFD if wcwidth() is -1 || czarkoff_AT_gmail.com

From: <git_AT_suckless.org>
Date: Mon, 03 Nov 2014 22:53:18 +0100

commit 11625c7166b7e4dad414606227acec2de1c36464
Author: czarkoff_AT_gmail.com <czarkoff_AT_gmail.com>
Date: Tue Oct 28 12:55:28 2014 +0100

    Replace character with U+FFFD if wcwidth() is -1
    
    Helpful when new Unicode codepoints are not recognized by libc.

diff --git a/st.c b/st.c
index 23dd7f1..ad52280 100644
--- a/st.c
+++ b/st.c
_AT_@ -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;
         }
Received on Mon Nov 03 2014 - 22:53:18 CET

This archive was generated by hypermail 2.3.0 : Mon Nov 03 2014 - 23:00:10 CET