Iconv transcoding failed on the UTF-8 encoding page in php

Source: Internet
Author: User
When iconv encounters a character that cannot be transcoded, the interrupted content is lost. the code is as follows: $ c & amp; lsquo; test & amp; bull; character transfer & amp; bull; Happy May Day! & Amp; rsquo; echoiconv (& amp; lsquo; UTF-8 & amp; prim

Iconv is interrupted when transcoding fails. the code is as follows:

  1. $ C = 'Test • character transfer • Happy May Day! ';
  2. Echo iconv ('utf-8', 'gbk', $ c );

Only output: After the test, the plenary session is lost.

Solution:Add // IGNORE, the code is as follows:

  1. $ C = 'Test • character transfer • Happy May Day! ';
  2. Echo iconv ('utf-8', 'gbk // IGNORE ', $ c );

Input: test character transfer for Happy May Day! Ignore indicates that the conversion error is ignored. without the ignore parameter, all strings after this character cannot be saved.

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.