From 23fdbc9ea6a6f5c93f042043f0407ed5d9bd0e5b Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 27 Apr 2016 09:36:25 +0000 Subject: [PATCH] Loads of platforms appear to have old or broken Unicode character type information and are missing widths for relatively common Unicode characters (so mbtowc() works, but wcwidth() fails). So if wcwidth() returns -1, assume a width of 1 instead of ignoring the character. --- utf8.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utf8.c b/utf8.c index 56281aa2..22ab62c1 100644 --- a/utf8.c +++ b/utf8.c @@ -119,6 +119,14 @@ utf8_width(wchar_t wc) width = wcwidth(wc); if (width < 0 || width > 0xff) { log_debug("Unicode %04x, wcwidth() %d", wc, width); + + /* + * Many platforms have no width for relatively common + * characters (wcwidth() returns -1); assume width 1 in this + * case and hope for the best. + */ + if (width < 0) + return (1); return (-1); } return (width);