function htmlConvertEncode($html){
// 检测编码
$encode = mb_detect_encoding($html, array("ASCII","UTF-8","GB2312","GBK","CP936","BIG5","EUC-CN"));
// 转码
if($encode != 'UTF-8'){
return mb_convert_encoding($html, 'UTF-8', $encode);
}
// 返回字符集
if('UTF-8' === true){
return $encode;
}
return $html;
}
我这个代码有个问题,就是少数的网页检测不出来编码。或者有没什么办法,能把所有非UTF8的代码转成UTF8?最好能全面点的