[imp] multibyte charset bugs and iconv support hack in imp (3.1)
Viljo Viitanen
vviitane+mail.imp@mappi.helsinki.fi
Sat Oct 26 02:34:38 2002
Me, a few moments ago, about imp decoding headers:
> That could be probably be fixed with some simple iconv magic, but I
> haven't checked that yet.
Well now I have. horde/lib/MIME.php (Horde 2.1), function decode: Add
ini_set('display_errors',0);
$conv=iconv(strtoupper($charset),strtoupper($GLOBALS['registry']->getCharset()).'//TRANSLIT',$decoded);
ini_set('display_errors',1);
if ($conv != FALSE) {
$decoded=$conv;
}
around line 204, before the line
return $preceding . $decoded . MIME::decode($rest);
Multiple character set support with less than 15 lines added :) But I
haven't checked what might have broken with these modifications.
Also, after these modifications one can add UTF8 support for writing mails,
by defining a new language/locale combo in horde/config/lang.php by addind
these two lines (if you have the en_US.UTF-8 locale in your system, that is):
$nls['languages']['en_US.UTF-8'] = 'English (Unicode)';
$nls['charsets']['en_US.UTF-8'] = 'UTF-8';
However, other Horde apps do not cope well with this at least if user data
is stored in other encodings (but this is the case anyway if one changes
from a language to another with a different charset). In Turba (1.0)
lib/Driver/ldap.php an explicit check is needed for utf8 encodings, but this
is very simple, if only utf8 encoded ldap directories are used (as is the
case with our installation): just change the two
if ($this->encoding == 'utf8' )
lines to
if ($this->encoding == 'utf8' && $GLOBALS['registry']->getCharset() != UTF-8')
--
Viljo Viitanen
Today has been a good hacking day.