How to determine the encoding of input characters on the page in the php tutorial
<? 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;
}
}
?>
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.
<? Php
/* 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