作者 邓超

编码问题

... ... @@ -21,10 +21,7 @@ class Fun {
*/
public static function mb_convert_encoding($str, $to, $from = null){
// 这个好像是阿拉伯编码
if($from == 'iso-8859-8-i'){
$from = 'iso-8859-8';
}
$from = self::getEncodingAliases($from);
try {
... ... @@ -35,4 +32,28 @@ class Fun {
}
/**
* 只有发现一个处理一个
* 获取编码
* @author:dc
* @time 2024/10/25 17:24
*/
public static function getEncodingAliases($coding){
$alias = [
"iso-8859-8-i" => "ISO-8859-8",
"iso-8859-8-e" => "ISO-8859-8",
"iso-8859-6-i" => "ISO-8859-6",
"iso-8859-6-e" => "ISO-8859-6",
];
$coding = strtolower($coding);
if(isset($alias[$coding])){
return $alias[$coding];
}
return $coding;
}
}
\ No newline at end of file
... ...
... ... @@ -296,7 +296,7 @@ class Header{
// 解码 这个函数好像已经转码了,
// iso-8859-8-i php 好像没有这个编码 ,阿拉伯 iso-8859-8
// =?iso-8859-8-i?B?4eTu+eog7PTw6en66iDg7CDn4fj6IERjb20gLSD08OnkIO7xIDgyNzUz?=
$str = str_replace("=?{$code[1]}?",'=?'.rtrim($code[1],'-i').'?',$str);
$str = str_replace("=?{$code[1]}?",'=?'.Fun::getEncodingAliases($code[1]).'?',$str);
$str = mb_decode_mimeheader($str);
... ...