php教程判斷頁面輸入字元編碼方法
function convtoutf8($str)
{
if( mb_detect_encoding($str,"utf-8, iso-8859-1, gbk")!="utf-8" )
{
return iconv("gbk","utf-8",$str);
}
else
{
return $str;
}
}
?>
不過有朋友說,mb_detect_encoding函數不支援gbk只支援utf-8,utf-7,ascii,euc-jp,sjis,eucjp-win,sjis-win,jis,iso-2022-jp和iso-8859-*
各位可以測試,我沒測試過。
/* detect character encoding with current detect_order */
echo mb_detect_encoding($str);
/* "auto" is expanded according to mbstring.language */
echo mb_detect_encoding($str, "auto");
/* specify encoding_list character encoding by comma separated list */
echo mb_detect_encoding($str, "jis, eucjp-win, sjis-win");
/* use array to specify encoding_list */
$ary[] = "ascii";
$ary[] = "jis";
$ary[] = "euc-jp";
echo
推薦一篇文章 http://www.bKjia.c0m/phper/php-cy/36263.htm
http://www.bkjia.com/PHPjc/632312.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632312.htmlTechArticlephp教程判斷頁面輸入字元編碼方法 ?php function convtoutf8($str) { if( mb_detect_encoding($str,utf-8, iso-8859-1, gbk)!=utf-8 ) { return iconv(gbk,utf-8,$str); } else {...