[Dovecot] Search with specified charset
Chris Wakelin
c.d.wakelin at reading.ac.uk
Thu Jul 14 00:06:29 EEST 2005
I've seen a problem with searching in the Prayer webmail client that
turns out to be caused by Prayer insisting on a charset called
"ISO-8859-1" and Dovecot, using Solaris iconv, not recognising it (all
the Solaris 8 iconv modules appear to be "ISO8859-1" etc. or just "8859-1").
This isn't a problem in Linux:
% iconv --list | grep 8859.1/
8859_1//
ISO-8859-1//
ISO8859-1//
ISO885911//
ISO_8859-1//
I've hacked together a patch for Dovecot to try matching without the
"ISO-" prefix if matching fails at first, which works for Solaris (as
would creating an extra symbolic link in /usr/lib/iconv or hacking
Prayer to use "ISO8859-1") and it doesn't break Linux, but it's not
pretty :(
Better may be to try substituting underscores, hyphens, spaces(?) and
nothing in the string, but that makes the change much more complicated!
Best Wishes,
Chris
--- dovecot-1.0-stable/src/lib-charset/charset-iconv.c.orig Mon Jan
31 16:37:55 2005
+++ dovecot-1.0-stable/src/lib-charset/charset-iconv.c Wed Jul 13
21:47:03 2005
@@ -36,9 +36,17 @@
ascii = FALSE;
cd = iconv_open("UTF-8", charset);
if (cd == (iconv_t)-1) {
- if (unknown_charset != NULL)
- *unknown_charset = TRUE;
- return NULL;
+ /* Try matching charset without "ISO" prefix */
+ if (strncasecmp(charset, "ISO-", 4) == 0 ||
+ strncasecmp(charset, "ISO ", 4) == 0)
+ cd = iconv_open("UTF-8", charset + 4);
+ else if (strncasecmp(charset, "ISO", 3) == 0)
+ cd = iconv_open("UTF-8", charset + 3);
+ if (cd == (iconv_t)-1) {
+ if (unknown_charset != NULL)
+ *unknown_charset = TRUE;
+ return NULL;
+ }
}
}
@@ -137,9 +145,17 @@
cd = iconv_open("UTF-8", charset);
if (cd == (iconv_t)-1) {
- if (unknown_charset != NULL)
- *unknown_charset = TRUE;
- return NULL;
+ /* Try matching charset without "ISO" prefix */
+ if (strncasecmp(charset, "ISO-", 4) == 0 ||
+ strncasecmp(charset, "ISO ", 4) == 0)
+ cd = iconv_open("UTF-8", charset + 4);
+ else if (strncasecmp(charset, "ISO", 3) == 0)
+ cd = iconv_open("UTF-8", charset + 3);
+ if (cd == (iconv_t)-1) {
+ if (unknown_charset != NULL)
+ *unknown_charset = TRUE;
+ return NULL;
+ }
}
if (unknown_charset != NULL)
--
--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-
Christopher Wakelin, c.d.wakelin at reading.ac.uk
IT Services Centre, The University of Reading, Tel: +44 (0)118 378 8439
Whiteknights, Reading, RG6 2AF, UK Fax: +44 (0)118 975 3094
More information about the dovecot
mailing list