作者 邓超

x

... ... @@ -37,7 +37,9 @@ class MailFun {
* @time 2023/3/27 13:55
*/
public static function mb_coding(string $str,array $appcode=[]){
$str = (new Header())->decode(trim($str," \t\n\r"));
$str = trim($str," \t\n\r");
preg_match("/^=\?(.*)\?/U",$str,$code);
$str = (new Header())->decode($str);
// if(str_starts_with($str, '=?')){
// try {
// $encode = @mb_detect_encoding($str, array_merge(array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'),$appcode));
... ... @@ -48,6 +50,9 @@ class MailFun {
//
// }
// }
if(($code[1]??'utf-8') != 'utf-8'){
$str = mb_convert_encoding($str, 'UTF-8', $code[1]);
}
return $str;
}
... ...