Fun.php 668 字节
<?php

namespace Lib\Imap;

/**
 * @author:dc
 * @time 2024/10/21 9:47
 * Class Fun
 * @package Lib\Imap
 */
class Fun {

    /**
     * 编码
     * @param $str
     * @param $to
     * @param null $from
     * @return string
     * @author:dc
     * @time 2024/10/21 9:43
     */
    public static function mb_convert_encoding($str, $to, $from = null){

        // 这个好像是阿拉伯编码
        if($from == 'iso-8859-8-i'){
            $from = 'iso-8859-8';
        }

        if ($from && in_array($from, mb_list_encodings())) {
            return mb_convert_encoding($str,$to,$from);
        }

        return mb_convert_encoding($str,$to);
    }


}