PHP Tutorial Judge page Input character encoding method
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;
}
}
?>
However, a friend said that the mb_detect_encoding function does not support GBK only support UTF-8,UTF-7,ASCII,EUC-JP,SJIS,EUCJP-WIN,SJIS-WIN,JIS,ISO-2022-JP and iso-8859- *
You can test it, I haven't tested it.
/* 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
Recommend a post http://www.bKjia.c0m/phper/php-cy/36263.htm
http://www.bkjia.com/PHPjc/632312.html www.bkjia.com true http://www.bkjia.com/PHPjc/632312.html techarticle PHP Tutorial Judge page input character encoding method? PHP function Convtoutf8 ($str) {if (Mb_detect_encoding ($str, Utf-8, Iso-8859-1, GBK)!=utf-8) {RET Urn Iconv (gbk,utf-8, $STR); } else {...