[imp] MIME and charsets
Dmitriy MiksIr
miksir at maker.ru
Tue Apr 11 05:41:59 PDT 2006
Hello!
I'v got the trouble with text/plain message with 8bit body and
non-english encoding.
For example, Content-Type: text/plain; charset=windows-1251
Troubles with as show full message, as preview message.
Let's see how preview generated:
if (($mimeid = $imp_contents->findBody(false)) !== null) {
$pmime = &$imp_contents->getDecodedMIMEPart($mimeid);
Here method $pmime->getCharset() return default 'us-ascii'.
How i understand, charset not found (because text is not MIME) and
us-ascii sets as default. But real charset of text is windows-1251.
I write workaround in imp/lib/Mailbox.php:
$ptext = String::convertCharset($ptext, $pmime->getCharset());
change to
$overview[$key]['imp_headers'] = &new IMP_Headers($header->uid);
$overview[$key]['imp_headers']->buildHeaders();
$contenttype = $overview[$key]['imp_headers']->getValue('content-type');
preg_match ( "/charset=\"?([\w\-]+)/i", $contenttype, $match );
$overview[$key]['def_charset'] = $match[1];
$ptext = String::convertCharset($ptext, ( ($pmime->getCharset() ==
"us-ascii") ? $overview[$key]['def_charset'] : $pmime->getCharset() ) );
But it's workaround, and hope, something will be changed in future versions.
More information about the imp
mailing list