aboutsummaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2023-01-27 23:04:47 +0000
committerJosh Rahm <rahm@google.com>2023-01-27 23:04:47 +0000
commite64dc03ff7b867826c7fc76d6fff210ad3382e33 (patch)
tree9cf71b02a7ee8f6d39ae1207201dc0745bdb8be5 /utf8.c
parentfb15fd116097b98c1b839cfdc76a7d84e206e6d5 (diff)
parentf5af3cfb211c12897b15e3b5a3b29c4bbb0493a8 (diff)
downloadrtmux-e64dc03ff7b867826c7fc76d6fff210ad3382e33.tar.gz
rtmux-e64dc03ff7b867826c7fc76d6fff210ad3382e33.tar.bz2
rtmux-e64dc03ff7b867826c7fc76d6fff210ad3382e33.zip
Merge remote-tracking branch 'upstream/master' into rahm
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/utf8.c b/utf8.c
index df75a769..042ddf89 100644
--- a/utf8.c
+++ b/utf8.c
@@ -229,14 +229,23 @@ utf8_width(struct utf8_data *ud, int *width)
case 0:
return (UTF8_ERROR);
}
+ log_debug("UTF-8 %.*s is %08X", (int)ud->size, ud->data, (u_int)wc);
#ifdef HAVE_UTF8PROC
*width = utf8proc_wcwidth(wc);
+ log_debug("utf8proc_wcwidth(%08X) returned %d", (u_int)wc, *width);
#else
*width = wcwidth(wc);
+ log_debug("wcwidth(%08X) returned %d", (u_int)wc, *width);
+ if (*width < 0) {
+ /*
+ * C1 control characters are nonprintable, so they are always
+ * zero width.
+ */
+ *width = (wc >= 0x80 && wc <= 0x9f) ? 0 : 1;
+ }
#endif
if (*width >= 0 && *width <= 0xff)
return (UTF8_DONE);
- log_debug("UTF-8 %.*s, wcwidth() %d", (int)ud->size, ud->data, *width);
return (UTF8_ERROR);
}