diff options
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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); } |