diff options
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -22,7 +22,6 @@ #include <errno.h> #include <stdlib.h> #include <string.h> -#include <vis.h> #include <wchar.h> #include "tmux.h" @@ -217,7 +216,11 @@ utf8_width(struct utf8_data *ud, int *width) { wchar_t wc; +#ifdef HAVE_UTF8PROC + switch (utf8proc_mbtowc(&wc, ud->data, ud->size)) { +#else switch (mbtowc(&wc, ud->data, ud->size)) { +#endif case -1: log_debug("UTF-8 %.*s, mbtowc() %d", (int)ud->size, ud->data, errno); @@ -227,6 +230,10 @@ utf8_width(struct utf8_data *ud, int *width) 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) { @@ -236,6 +243,7 @@ utf8_width(struct utf8_data *ud, int *width) */ *width = (wc >= 0x80 && wc <= 0x9f) ? 0 : 1; } +#endif if (*width >= 0 && *width <= 0xff) return (UTF8_DONE); return (UTF8_ERROR); |