With the Iconv function:
iconv ("Utf-8", "gb2312", "ABC Sunshine 123");
It is said that this is better, you can ignore the conversion error!
iconv ("Utf-8", "Gb2312//ignore", "ABC Sunshine 123");
Mb_convert_encoding's usage is in the official view:
http://cn.php Tutorial. net/manual/zh/function.mb-convert-encoding.php
Make a GBK to Utf-8
< PHP
Header ("content-type:text/html; Charset=utf-8 ");
Echo mb_convert_encoding ("My Friend", "Utf-8", "GBK");
?>
One more gb2312 to Big5.
< PHP
Header ("content-type:text/html; Charset=big5 ");
Echo mb_convert_encoding ("You Are my Friend", "Big5", "gb2312");
?>
However, to use the above function requires installation but first enable the mbstring extension library.
Another function in PHP, Iconv, is also used to convert string encodings, similar to functions on the upper function.
Here are a few more examples:
Iconv-convert string to requested character encoding
(PHP 4 >= 4.0.5, PHP 5)
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 expansion Library, in php.ini; Extension=php_mbstring.dll in front of; Remove
Mb_convert_encoding can specify a variety of input encoding, it will automatically identify according to the content, but the execution efficiency is much worse than the iconv;
http://www.bkjia.com/PHPjc/632355.html www.bkjia.com true http://www.bkjia.com/PHPjc/632355.html techarticle with the Iconv function: Iconv (utf-8, GB2312, ABC Sunshine 123); It is said that this is better, you can ignore the conversion error! Iconv (Utf-8, Gb2312//ignore, ABC Sunshine 123); The use of mb_convert_encoding ...