In PHP, GB2312 encoding is converted to UTF8 encoding.
Source: Internet
Author: User
The original webpage is GB2312 encoded. after reading it, garbled characters are displayed on the UTF8 page. you need to convert GB2312 encoding to UTF8 encoding. you can use mb_convert_encoding for conversion or iconv for conversion, in addition, if you want to read data from the database, you can also specify the webpage encoding to use mb_internal_encoding. the original webpage is GB2312 encoded. after reading the code, garbled characters are displayed on the UTF8 page. you need to convert GB2312 encoding to UTF8 encoding, you can use mb_convert_encoding for conversion or iconv for conversion. if you want to read data from the database, you can also specify the webpage encoding to use mb_internal_encoding.
For example,
Encode GB2312 to UTF8
$ String = "I am GB2312 encoded ";
$ String = mb_convert_encoding ($ string, "UTF8", "GB2312 ");
// Or
$ String = iconv ("GB2312", "UTF-8", "This is a test .");
?>
All of the above require database support
Extension_dir = D:/software/php/extensions/(your PHP Installation Path)
; Extension = php_mbstring.dll
Remove the semicolon
ICONV needs to be downloaded and installed
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.