如果不清楚字符串的编码格式的话,就可以将这段字符这样检查:
$encode = mb_detect_encoding($string, array("ASCII",'UTF-8′,"GB2312′,"GBK",'BIG5′));
echo $encode;
这样就能知道它是什么编码的了。后续操作还可以为其转码:
if ($encode == “UTF-8″){
$string = iconv("UTF-8″,"GBK",$string);
}
时间: 2024-09-28 17:32:44
如果不清楚字符串的编码格式的话,就可以将这段字符这样检查:
$encode = mb_detect_encoding($string, array("ASCII",'UTF-8′,"GB2312′,"GBK",'BIG5′));
echo $encode;
这样就能知道它是什么编码的了。后续操作还可以为其转码:
if ($encode == “UTF-8″){
$string = iconv("UTF-8″,"GBK",$string);
}