正在显示
2 个修改的文件
包含
39 行增加
和
1 行删除
lib/Imap/Fun.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace Lib\Imap; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * @author:dc | ||
| 7 | + * @time 2024/10/21 9:47 | ||
| 8 | + * Class Fun | ||
| 9 | + * @package Lib\Imap | ||
| 10 | + */ | ||
| 11 | +class Fun { | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 编码 | ||
| 15 | + * @param $str | ||
| 16 | + * @param $to | ||
| 17 | + * @param null $from | ||
| 18 | + * @return string | ||
| 19 | + * @author:dc | ||
| 20 | + * @time 2024/10/21 9:43 | ||
| 21 | + */ | ||
| 22 | + public static function mb_convert_encoding($str, $to, $from = null){ | ||
| 23 | + | ||
| 24 | + // 这个好像是阿拉伯编码 | ||
| 25 | + if($from == 'iso-8859-8-i'){ | ||
| 26 | + $from = 'iso-8859-8'; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + if ($from && in_array($from, mb_list_encodings())) { | ||
| 30 | + return mb_convert_encoding($str,$to,$from); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + return mb_convert_encoding($str,$to); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + | ||
| 37 | +} |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace Lib\Imap\Parse; | 3 | namespace Lib\Imap\Parse; |
| 4 | 4 | ||
| 5 | use Lib\Imap\DataArray; | 5 | use Lib\Imap\DataArray; |
| 6 | +use Lib\Imap\Fun; | ||
| 6 | 7 | ||
| 7 | /** | 8 | /** |
| 8 | * 邮件内容 | 9 | * 邮件内容 |
| @@ -296,7 +297,7 @@ class Body { | @@ -296,7 +297,7 @@ class Body { | ||
| 296 | if($item->eq('charset','utf-8')){ | 297 | if($item->eq('charset','utf-8')){ |
| 297 | return $item->body; | 298 | return $item->body; |
| 298 | }else{ | 299 | }else{ |
| 299 | - return mb_convert_encoding($item->body,'utf-8',$item->charset); | 300 | + return Fun::mb_convert_encoding($item->body,'utf-8',$item->charset); |
| 300 | } | 301 | } |
| 301 | } | 302 | } |
| 302 | } | 303 | } |
-
请 注册 或 登录 后发表评论