diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2016-09-01 20:40:03 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2016-09-01 20:40:03 +0100 |
commit | 6c94774b70f72952c4c512e4aa59a207ca1c34f2 (patch) | |
tree | 04502f9607958f3b4559e3bac5e5668e8d517ab0 /utf8.c | |
parent | ae297cb487590d0bb8e42e21e28926a1f957ad0b (diff) | |
download | rtmux-6c94774b70f72952c4c512e4aa59a207ca1c34f2.tar.gz rtmux-6c94774b70f72952c4c512e4aa59a207ca1c34f2.tar.bz2 rtmux-6c94774b70f72952c4c512e4aa59a207ca1c34f2.zip |
Add support for using utf8proc with --enable-utf8proc, useful for platforms
(like OS X) where the system implementation is crap. From Joshua Rubin.
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -109,7 +109,11 @@ utf8_width(wchar_t wc) { int width; +#ifdef HAVE_UTF8PROC + width = utf8proc_wcwidth(wc); +#else width = wcwidth(wc); +#endif if (width < 0 || width > 0xff) { log_debug("Unicode %04x, wcwidth() %d", wc, width); @@ -135,7 +139,11 @@ utf8_width(wchar_t wc) enum utf8_state utf8_combine(const struct utf8_data *ud, 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); @@ -155,7 +163,11 @@ utf8_split(wchar_t wc, struct utf8_data *ud) char s[MB_LEN_MAX]; int slen; +#ifdef HAVE_UTF8PROC + slen = utf8proc_wctomb(s, wc); +#else slen = wctomb(s, wc); +#endif if (slen <= 0 || slen > (int)sizeof ud->data) return (UTF8_ERROR); |