正在显示
1 个修改的文件
包含
6 行增加
和
13 行删除
@@ -38,21 +38,14 @@ class MailFun { | @@ -38,21 +38,14 @@ class MailFun { | ||
38 | */ | 38 | */ |
39 | public static function mb_coding(string $str,array $appcode=[]){ | 39 | public static function mb_coding(string $str,array $appcode=[]){ |
40 | $str = trim($str," \t\n\r"); | 40 | $str = trim($str," \t\n\r"); |
41 | - preg_match("/^=\?(.*)\?/U",$str,$code); | ||
42 | $str = (new Header())->decode($str); | 41 | $str = (new Header())->decode($str); |
43 | -// if(str_starts_with($str, '=?')){ | ||
44 | -// try { | ||
45 | -// $encode = @mb_detect_encoding($str, array_merge(array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'),$appcode)); | ||
46 | -// if($encode){ | ||
47 | -// return @mb_convert_encoding($str, 'UTF-8', $encode); | ||
48 | -// } | ||
49 | -// }catch (\Throwable $e){ | ||
50 | -// | ||
51 | -// } | ||
52 | -// } | ||
53 | - if(($code[1]??'utf-8') != 'utf-8'){ | ||
54 | - $str = mb_convert_encoding($str, 'UTF-8', $code[1]); | 42 | + try { |
43 | + $encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5')); | ||
44 | + if($encode && $encode != 'UTF-8'){ | ||
45 | + $str = mb_convert_encoding($str, 'UTF-8', $encode); | ||
55 | } | 46 | } |
47 | + }catch (\Throwable $e){} | ||
48 | + | ||
56 | 49 | ||
57 | return $str; | 50 | return $str; |
58 | } | 51 | } |
-
请 注册 或 登录 后发表评论