日期:2015/6/28来源: IT猫扑网
本篇文章是对php获取字符串的编码格式的方法(函数)进行了详细的分析介绍,需要的朋友参考下
如果不清楚字符串的编码格式的话,就可以将这段字符这样检查:
$encode = mb_detect_encoding($string, array("ASCII",'UTF-8′,"GB2312′,"GBK",'BIG5′));
echo $encode;
这样就能知道它是什么编码的了。后续操作还可以为其转码:
if ($encode == "UTF-8″){
$string = iconv("UTF-8″,"GBK",$string);
}
$type=mb_detect_encoding($title, array("ASCII","UTF-8","GB2312","GBK","BIG5"));
if($type=="UTF-8"){
$title = iconv('utf-8','gbk//IGNORE',$title);
}
相关文章
相关下载
网友评论