Phpiconv function error: detectedanillegalcharacterininputstring

Source: Internet
Author: User
Add & quot; // ignore & quot; after the output character encoding string, such as iconv ('utf-8', 'gb2312 // ignore ', $ content ), in this way, we ignore the characters that cannot be converted and avoid errors but cannot output them correctly (that is, no blank space or output)

After capturing web page data tonight and converting the code through the iconv function, an error is reported:


notice: iconv() [function.iconv]: detected an illegal character in input string ...
The error is that the content contains characters that do not support conversion.


There are two solutions:

1. extend the output character encoding range, such as iconv ('utf-8', 'gbk', $ content). This can be output correctly because gbk supports a wider range of characters;

2. add "// ignore" after the output character encoding string, such as iconv ('utf-8', 'gb2312 // ignore ', $ content ), in this way, you can ignore characters that cannot be converted and avoid errors but cannot output them correctly (that is, blank spaces and outputs ).

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.