用mb_detect_encoding获得的返回值是cp936这个与GBK对应?
通过mb_convert_encoding转码后,虽然文本显示正常,但是在用mb_detect_encoding检测文本编码格式,仍然是cp936,并没有改变,这是为什么?
代码如下:
$file_contents = fread($file,$fileSize);
$typeofData = mb_detect_encoding($file_contents,array("GBK","GB2312","UTF-8","ASCII","BIG5"));
if ($typeofData != "UTF-8"){
// $file_contents = iconv("GBK","UTF-8",$file_contents);
$file_contents = mb_convert_encoding($file_contents,"UTF-8","GBK");
}
echo mb_detect_encoding($file_contents,array("GBK","GB2312","UTF-8","ASCII","BIG5"))."<br/>";
echo $file_contents;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…