Code for converting UTF-8 and GB2312 encoding using php
Source: Internet
Author: User
Php implements a function for mutual conversion between UTF-8 and GB2312 encoding. if you need it, refer
The code is as follows:
/*************************************** *****
*
* Function name: get_utf8_to_gb ($ value)
* Use: utf8 encoded string to gb2312 encoding
* Author: Liu Xianzhong
* Date: 2011-11-09
*
**************************************** ****/
Function get_utf8_to_gb ($ value ){
$ Value_1 = $ value;
$ Value_2 = @ iconv ("UTF-8", "gb2312 // IGNORE", $ value_1); // use @ to resist errors, if a character does not have a corresponding character in the target character set, the subsequent part of the character is ignored. that is, the result string is incomplete and you need to use // IGNORE
$ Value_3 = @ iconv ("gb2312", "UTF-8 // IGNORE", $ value_2 );
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.