From 3a9d4c01e5135f6d5b2aecdaf698d1d960387df9 Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Wed, 25 Mar 2015 20:27:02 -0600 Subject: * new version 2.20.4 * If the charset of a message can not be determined, use the value set in the "Unknown Character Set" option. * Resizing setup screen will redraw screen. * Unix Alpine only. Experimental: If Alpine/Pico finds a UCS4 code in the width ambiguous zone, it will use other means to determine the width, such as call wcwidth. --- imap/src/c-client/utf8.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'imap/src/c-client/utf8.c') diff --git a/imap/src/c-client/utf8.c b/imap/src/c-client/utf8.c index 3f75ed98..e734a6bb 100644 --- a/imap/src/c-client/utf8.c +++ b/imap/src/c-client/utf8.c @@ -38,6 +38,7 @@ * details. */ +static ucs4width_t ucs4width = NIL; /* Character set conversion tables */ @@ -2315,6 +2316,7 @@ unsigned long ucs4_titlecase (unsigned long c) long ucs4_width (unsigned long c) { long ret; + ucs4width_t uw = (ucs4width_t) utf8_parameters(GET_UCS4WIDTH, NIL); /* out of range, not-a-char, or surrogates */ if ((c > UCS4_MAXUNICODE) || ((c & 0xfffe) == 0xfffe) || ((c >= UTF16_SURR) && (c <= UTF16_MAXSURR))) ret = U4W_NOTUNCD; @@ -2341,7 +2343,8 @@ long ucs4_width (unsigned long c) case 2: /* double-width */ break; case 3: /* ambiguous width */ - ret = (c >= 0x2100) ? 2 : 1;/* need to do something better than this */ + ret = uw ? (*uw)(c) /* this is better than the line below */ + : (c >= 0x2100) ? 2 : 1;/* need to do something better than this */ break; } return ret; @@ -2581,3 +2584,17 @@ unsigned long ucs4_decompose_recursive (unsigned long c,void **more) } return c; } + +void *utf8_parameters (long function,void *value) +{ + void *ret; + + switch(function){ + case SET_UCS4WIDTH: + ucs4width = (ucs4width_t) value; + case GET_UCS4WIDTH: + ret = (void *) ucs4width; + break; + } + return ret; +} -- cgit v1.2.3-54-g00ecf