summaryrefslogtreecommitdiff
path: root/imap
diff options
context:
space:
mode:
Diffstat (limited to 'imap')
-rw-r--r--imap/src/c-client/mail.c1
-rw-r--r--imap/src/c-client/mail.h4
-rw-r--r--imap/src/c-client/utf8.c19
-rw-r--r--imap/src/c-client/utf8.h1
4 files changed, 23 insertions, 2 deletions
diff --git a/imap/src/c-client/mail.c b/imap/src/c-client/mail.c
index 03952d2e..da703a0d 100644
--- a/imap/src/c-client/mail.c
+++ b/imap/src/c-client/mail.c
@@ -650,6 +650,7 @@ void *mail_parameters (MAILSTREAM *stream,long function,void *value)
if (r = smtp_parameters (function,value)) ret = r;
if (r = env_parameters (function,value)) ret = r;
if (r = tcp_parameters (function,value)) ret = r;
+ if (r = utf8_parameters (function,value)) ret = r;
if (stream && stream->dtb) {/* if have stream, do for its driver only */
if (r = (*stream->dtb->parameters) (function,value)) ret = r;
}
diff --git a/imap/src/c-client/mail.h b/imap/src/c-client/mail.h
index 2accc85b..7595bf59 100644
--- a/imap/src/c-client/mail.h
+++ b/imap/src/c-client/mail.h
@@ -142,7 +142,8 @@
#define SET_RFC822OUTPUTFULL (long) 160
#define GET_BLOCKENVINIT (long) 161
#define SET_BLOCKENVINIT (long) 162
-
+#define GET_UCS4WIDTH (long) 163
+#define SET_UCS4WIDTH (long) 164
/* 2xx: environment */
#define GET_USERNAME (long) 201
#define SET_USERNAME (long) 202
@@ -1325,6 +1326,7 @@ typedef void *(*mailcache_t) (MAILSTREAM *stream,unsigned long msgno,long op);
typedef long (*mailproxycopy_t) (MAILSTREAM *stream,char *sequence,
char *mailbox,long options);
typedef long (*tcptimeout_t) (long overall,long last, char *host);
+typedef long (*ucs4width_t) (unsigned long c);
typedef void *(*authchallenge_t) (void *stream,unsigned long *len);
typedef long (*authrespond_t) (void *stream,char *s,unsigned long size);
typedef long (*authcheck_t) (void);
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;
+}
diff --git a/imap/src/c-client/utf8.h b/imap/src/c-client/utf8.h
index 105f856d..d080c1b0 100644
--- a/imap/src/c-client/utf8.h
+++ b/imap/src/c-client/utf8.h
@@ -582,3 +582,4 @@ long utf8_strwidth (unsigned char *s);
long utf8_textwidth (SIZEDTEXT *utf8);
unsigned long ucs4_decompose (unsigned long c,void **more);
unsigned long ucs4_decompose_recursive (unsigned long c,void **more);
+void *utf8_parameters (long function, void *value);