summaryrefslogtreecommitdiffstats
path: root/utf8.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2021-02-10 17:18:37 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2021-02-10 17:18:37 +0000
commit679b2288e81a0aa1c375a5ae16c23866114ed766 (patch)
treea4a4f9b0243d7ea386c7180f127b0fb94fae1bc9 /utf8.c
parent5b6d4c4fd1c25a6bcfdcf9c5eb1e9399f0d169dd (diff)
Restore utf8proc bits that went missing, GitHub issue 2564.
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/utf8.c b/utf8.c
index 458363b8..f43945e6 100644
--- a/utf8.c
+++ b/utf8.c
@@ -216,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);
@@ -225,7 +229,11 @@ utf8_width(struct utf8_data *ud, int *width)
case 0:
return (UTF8_ERROR);
}
+#ifdef HAVE_UTF8PROC
+ *width = utf8proc_wcwidth(wc);
+#else
*width = wcwidth(wc);
+#endif
if (*width >= 0 && *width <= 0xff)
return (UTF8_DONE);
log_debug("UTF-8 %.*s, wcwidth() %d", (int)ud->size, ud->data, *width);