PHP iconv function parameter differences

Source: Internet
Author: User
Tags translit

This article was also published in HTTPS://GITHUB.COM/ZHANGYACHEN/ZHANGYACHEN.GITHUB.IO/ISSUES/57

User input: Intel? Cool core? i7 processor prowess

Case1
$valueiconv("UTF-8","GBK//TRANSLIT",$value);

Results:

英特尔(R) 酷睿(TM) i7处理器大显身手
Case2
$valueiconv("UTF-8","GBK//IGNORE",$value);

Results:

英特尔 酷睿 i7处理器大显身手
Case3
$valueiconv("UTF-8","GBK",$value);

Results:

英特尔
Case4
mb_convert_encoding($value,"GBK","UTF-8");

Results:

英特尔? 酷睿? i7处理器大显身手
Analysis
iconv ( string $in_charset , string $out_charset , string $str )
    • If you add a string//translit after Out_charset, the transliteration (transliteration) feature is enabled. This means that when a character cannot be represented by the target character set, it can be approximated by one or more similar characters.
    • If you add a string//ignore, characters that cannot be expressed in the target character set are silently discarded.
    • If no string is added after the out_charset, it is truncated starting with the first unrecognized character and generates a e_notice. So the content behind is discarded.

PHP iconv function parameter differences

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.