--- ./lib/IMP.php-dist 2004-01-28 10:38:00.000000000 +0200 +++ ./lib/IMP.php 2004-05-18 01:32:00.000000000 +0300 @@ -977,8 +977,28 @@ $msg = convert_cyr_string($msg, 'm', 'w'); } else if ($charset == 'dos') { $msg = convert_cyr_string($msg, 'a', 'w'); - } else if (stristr($mime->charset, 'koi8-r')) { +// } else if (stristr($mime->charset, 'koi8-r')) { + } else if ((stristr($mime->charset, 'koi8-r')) or + (stristr($mime->charset, 'koi8r')) or (stristr($mime->charset, 'koi8-ru')) or + (stristr($mime->charset, 'koi8'))) { $msg = convert_cyr_string($msg, 'k', 'w'); + } else if (stristr($mime->charset, 'iso-8859-5')) { + $msg = convert_cyr_string($msg, 'i', 'w'); + } else if ((stristr($mime->charset, 'x-cp866')) or + (stristr($mime->charset, 'csibm866')) or (stristr($mime->charset, 'ibm866'))) { + $msg = convert_cyr_string($msg, 'd', 'w'); + } else if ((stristr($mime->charset, 'x-mac-cyrillic')) or + (stristr($mime->charset, 'maccyrillic')) or (stristr($mime->charset, 'mac-cyrillic'))) { + $msg = convert_cyr_string($msg, 'm', 'w'); + } elseif ((stristr($mime->charset, 'utf-8')) or (stristr($mime->charset, 'utf8'))) { + if (function_exists('mb_convert_encoding')) { + $decoded_tmp = @mb_convert_encoding($msg, 'WINDOWS-1251', 'UTF8'); + if ($decoded_tmp) { + $msg = $decoded_tmp; + } else { + $msg = convert_cyr_string(@mb_convert_encoding($msg, 'ISO-8859-5', 'UTF8'), 'i', 'w'); + } + } } } if (stristr($registry->getCharset(), 'koi8-r')) { @@ -990,8 +1010,27 @@ $msg = convert_cyr_string($msg, 'm', 'k'); } else if ($charset == 'dos') { $msg = convert_cyr_string($msg, 'a', 'k'); - } else if (stristr($mime->charset, 'windows-1251')) { +// } else if (stristr($mime->charset, 'windows-1251')) { + } else if ((stristr($mime->charset, 'windows-1251')) or + (stristr($mime->charset, 'cp1251'))) { $msg = convert_cyr_string($msg, 'w', 'k'); + } else if (stristr($mime->charset, 'iso-8859-5')) { + $msg = convert_cyr_string($msg, 'i', 'k'); + } else if ((stristr($mime->charset, 'x-cp866')) or + (stristr($mime->charset, 'csibm866')) or (stristr($mime->charset, 'ibm866'))) { + $msg = convert_cyr_string($msg, 'd', 'k'); + } else if ((stristr($mime->charset, 'x-mac-cyrillic')) or + (stristr($mime->charset, 'maccyrillic')) or (stristr($mime->charset, 'mac-cyrillic'))) { + $msg = convert_cyr_string($msg, 'm', 'k'); + } elseif ((stristr($mime->charset, 'utf-8')) or (stristr($mime->charset, 'utf8'))) { + if (function_exists('mb_convert_encoding')) { + $decoded_tmp = @mb_convert_encoding($msg, 'KOI8-R', 'UTF8'); + if ($decoded_tmp) { + $msg = $decoded_tmp; + } else { + $msg = convert_cyr_string(@mb_convert_encoding($msg, 'ISO-8859-5', 'UTF8'), 'i', 'k'); + } + } } }