PHP Judgment page Input character encoding method _php Tutorial

Source: Internet
Author: User
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 {...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.