Added some charset aliases to fix typical mis-labelling (#1484565)

release-0.6
thomascube 17 years ago
parent 5bc0ab10fc
commit 38b012e072

@ -908,17 +908,25 @@ function rcube_charset_convert($str, $from, $to=NULL)
if ($from==$to || $str=='' || empty($from)) if ($from==$to || $str=='' || empty($from))
return $str; return $str;
$aliases = array(
'UNKNOWN-8BIT' => 'ISO-8859-15',
'X-UNKNOWN' => 'ISO-8859-15',
'X-USER-DEFINED' => 'ISO-8859-15',
'ISO-8859-8-I' => 'ISO-8859-8',
'KS_C_5601-1987' => 'EUC-KR',
'GB2312' => 'GB18030'
);
// convert charset using iconv module // convert charset using iconv module
if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7')
{ {
$iconv_map = array('KS_C_5601-1987' => 'EUC-KR'); return iconv(($aliases[$from] ? $aliases[$from] : $from), ($aliases[$to] ? $aliases[$to] : $to) . "//IGNORE", $str);
return iconv(($iconv_map[$from] ? $iconv_map[$from] : $from), ($iconv_map[$to] ? $iconv_map[$to] : $to) . "//IGNORE", $str);
} }
// convert charset using mbstring module // convert charset using mbstring module
if ($MBSTRING) if ($MBSTRING)
{ {
$mb_map = array('UTF-7' => 'UTF7-IMAP', 'KS_C_5601-1987' => 'EUC-KR'); $mb_map = $aliases + array('UTF-7' => 'UTF7-IMAP');
// return if convert succeeded // return if convert succeeded
if (($out = mb_convert_encoding($str, ($mb_map[$to] ? $mb_map[$to] : $to), ($mb_map[$from] ? $mb_map[$from] : $from))) != '') if (($out = mb_convert_encoding($str, ($mb_map[$to] ? $mb_map[$to] : $to), ($mb_map[$from] ? $mb_map[$from] : $from))) != '')

Loading…
Cancel
Save