字符串转编码

    技术2022-07-11  116

    字符串转编码

    /** * 描述 : 字符串转编码 * 参数 :$str 字符串 $code 要转换的编码 默认UTF-8 * 作者 : Smart.Chen */ function strEncode($str, $code = 'UTF-8') { $encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5','LATIN1')); if ($encode != $code) { return mb_convert_encoding($str, $code, $encode); } else { return $str; } }
    Processed: 0.011, SQL: 9