PHP Utf-8 and gb2312 encoding conversion garbled problem _php Tutorial

Source: Internet
Author: User
After a time of PHP + MSSQL, the feeling of MSSQL support for the code is not very good (in fact, I did not grasp it well), but has not yet come to the urgent exchange of databases, only on the point, and today in the submission of data errors.

After a time of PHP + MSSQL, the feeling of MSSQL support for the code is not very good (in fact, I did not grasp it well), but has not yet come to the urgent exchange of databases, only on the point, and today in the submission of data errors.

Because the content of the submitted ntext field is more, about a few KB, so I misunderstood, thinking that the article is too long to cause errors. I look at the PHP configuration, I found that PHP support for Mssql.textsize is already in the K, how wrong? When the error is turned on, it is not the article too long, but the error caused by the encoding. The error is as follows:

The code is as follows Copy Code
Notice:iconv () [Function.iconv]: detected an illegal character in input string in ....

English is really bad, just know iconv () function problem. Google Translate, said to be an illegal character detected in the input string. Dawned.

The solution to finding the problem online based on the error is to add a//ignore to the second parameter of Iconv (), which means ignoring the error. The code is as follows:

The code is as follows Copy Code
Iconv ("Utf-8", "Gbk//ignore", $str);

Tested and submitted successfully.

Note: The Netizen experience, the scope of GBK is bigger than gb2313, so the error rate with GBK coding is smaller than gb2313.

http://www.bkjia.com/PHPjc/632194.html www.bkjia.com true http://www.bkjia.com/PHPjc/632194.html techarticle after a time of PHP + MSSQL, the feeling of MSSQL support for the code is not very good (in fact, I did not grasp it well), but has not come to the urgent exchange of databases, only on the point, today ...

  • 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.