Text encoding conversion mb_convert_encoding ()
Mb_convert_encoding ($ str, $ encoding1, $ encoding2)
$ Str: string to be converted to Encoding
$ Encoding1: Target encoding, such as UTF-8, gbk, and uppercase/lowercase
$ Encoding2: original encoding, such as UTF-8, gbk, and uppercase/lowercase
Instance 1
Copy codeThe Code is as follows:
<? Php
$ Str = 'feet House: http://www.jb51.net ';
Echo mb_convert_encoding ($ str, "UTF-8"); // encode to UTF-8
?>
Copy codeThe Code is as follows:
<? Php
$ Str = 'feet House: http://www.jb51.net ';
Echo mb_convert_encoding ($ str, "UTF-8", "GBK"); // It is known that the original encoding is GBK and is converted to UTF-8
?>
Copy codeThe Code is as follows:
<? Php
$ Str = 'feet House: http://www.jb51.net ';
Echo mb_convert_encoding ($ str, "UTF-8", "auto"); // unknown original encoding, converted to UTF-8 after auto Detection
?>
Use of the encoding and conversion functions mb_convert_encoding and iconv in PHP