summaryrefslogtreecommitdiff
path: root/imap/src/c-client/utf8.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2015-03-25 20:27:02 -0600
committerEduardo Chappa <chappa@washington.edu>2015-03-25 20:27:02 -0600
commit3a9d4c01e5135f6d5b2aecdaf698d1d960387df9 (patch)
tree01b45596b7334d2f9d1298f099ca4f037f2e69b7 /imap/src/c-client/utf8.c
parent955a543f9ac3bb29b88a42d0520ac68324c2f6fa (diff)
downloadalpine-3a9d4c01e5135f6d5b2aecdaf698d1d960387df9.tar.xz
* 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.
Diffstat (limited to 'imap/src/c-client/utf8.c')
-rw-r--r--imap/src/c-client/utf8.c19
1 files changed, 18 insertions, 1 deletions
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;
+}