PHP string Encoding problem
PHP Code conversion function
Mb_convert_encoding-convert character encoding (PHP 4 >= 4.0.6, PHP 5)
Usage:
String mb_convert_encoding (String str, string to_encoding [, mixed from_encoding])
Need to enable mbstring extension library, in php.ini; Extension=php_mbstring.dll in front of; Remove
String Iconv (String in_charset, String out_charset, String str)
Attention:
The second parameter, in addition to specifying the encoding to be converted to, can also add two suffixes://translit and//ignore,
which
Translit automatically converts characters that cannot be converted directly into one or more approximate characters,
IGNORE ignores characters that cannot be converted, and the default effect is to truncate from the first illegal character.
Returns the converted string or FALSE on failure.
Second, automatically get the string encoding function
When using the Mb_detect_encoding function in PHP to encode recognition, many people have encountered the problem of identifying the coding error, for example, with GB2312 and UTF-8, or UTF-8 and GBK (here is mainly for cp936 judgment), online said that because the character is short, Mb_detect_encoding will have a miscarriage of error.
For example:
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