Php determines the encoding of the input characters on the page. In the php Tutorial, how does one determine the encoding of the input characters on the page? Phpfunctionconvtoutf8 ($ str) {if (mb_detect_encoding ($ str, UTF-8, ISO-8859-1, gbk )! UTF-8) {returniconv (gbk, UTF-8, $ str);} else {php Tutorial judgment 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;
}
}
?>
But some friends said, 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 have never 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
Http://www.bKjia. c0m/phper/php-cy/36263.htm recommended article
Why? Php function convtoutf8 ($ str) {if (mb_detect_encoding ($ str, UTF-8, ISO-8859-1, gbk )! = Utf-8) {return iconv (gbk, UTF-8, $ str);} else {...