PHP function Iconv Intercept error Resolution _php tutorial

Source: Internet
Author: User
iconv function: The requirement to convert character encoding of a string
Syntax: string Iconv(String In_charset, String out_charset, String str)

When using this function for string encoding conversions, it is important to note that if you convert Utf-8 to gb2312, a string truncation can occur.

This can be resolved using the following methods:
$str =iconv (Utf-8, "Gb2312//translit", file_get_contents ($filepath));
That is, in the second parameter, add the Red Word section, meaning: If you cannot find a character that matches the source encoding in the target encoding, a similar character is selected for conversion.
This can also be used here://ignore This parameter, which means that characters that cannot be converted are ignored.

http://www.bkjia.com/PHPjc/486062.html www.bkjia.com true http://www.bkjia.com/PHPjc/486062.html techarticle iconv function: The requirement syntax for converting character encodings of strings: String Iconv (String in_charset, String out_charset, String str) when using this function for string encoding conversions ...

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