public static function strToGBK($strText) { $encode = mb_detect_encoding($strText, array('UTF-8','GB2312','GBK')); if($encode == "UTF-8") { return @iconv('UTF-8','GB18030',$strText); } else { return $strText; } }
mb_detect_encoding:检测字符的编码
本文共 372 字,大约阅读时间需要 1 分钟。
public static function strToGBK($strText) { $encode = mb_detect_encoding($strText, array('UTF-8','GB2312','GBK')); if($encode == "UTF-8") { return @iconv('UTF-8','GB18030',$strText); } else { return $strText; } }
mb_detect_encoding:检测字符的编码
转载于:https://www.cnblogs.com/longzhongren/p/5910431.html