diff options
author | nicm <nicm> | 2016-04-26 07:33:36 +0000 |
---|---|---|
committer | nicm <nicm> | 2016-04-26 07:33:36 +0000 |
commit | d303e552582e311aae9a246651dc3816775707b7 (patch) | |
tree | 2d18aa5448c7201e6d34e413b4d11c23f13d799b /utf8.c | |
parent | 6bf2a43e675c9c1d2cd9b13f326f010e7fba727d (diff) |
Log wcwidth() and mbtowc() failure to make it easier to debug a Unicode
codepoint not appearing.
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -18,6 +18,7 @@ #include <sys/types.h> +#include <errno.h> #include <stdlib.h> #include <string.h> #include <vis.h> @@ -116,8 +117,10 @@ utf8_width(wchar_t wc) int width; width = wcwidth(wc); - if (width < 0 || width > 0xff) + if (width < 0 || width > 0xff) { + log_debug("Unicode %04x, wcwidth() %d", wc, width); return (-1); + } return (width); } @@ -127,6 +130,8 @@ utf8_combine(const struct utf8_data *ud, wchar_t *wc) { switch (mbtowc(wc, ud->data, ud->size)) { case -1: + log_debug("UTF-8 %.*s, mbtowc() %d", (int)ud->size, ud->data, + errno); mbtowc(NULL, NULL, MB_CUR_MAX); return (UTF8_ERROR); case 0: |