Home >Backend Development >PHP Tutorial >Introduction to PHP mb_convert_encoding text encoding conversion function_PHP tutorial

Introduction to PHP mb_convert_encoding text encoding conversion function_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:23:081043browse

Text encoding conversion mb_convert_encoding()
mb_convert_encoding( $str, $encoding1,$encoding2 )

$str, the encoding string to be converted
$encoding1, target encoding, such as utf-8, gbk, both upper and lower case can be used
$encoding2, original encoding, such as utf-8, gbk, both upper and lower case can be used

Example 1

Copy code The code is as follows:

$str='Script Home: http://www.jb51.net';
echo mb_convert_encoding($str , "UTF-8"); //Convert encoding to utf-8
?>

Copy code The code is as follows :

$str='Script Home: http://www.jb51.net';
echo mb_convert_encoding($str, "UTF-8" , "GBK"); //The original encoding is known to be GBK, converted to utf-8
?>

Copy code The code is as follows:

$str='Script Home: http://www.jb51.net';
echo mb_convert_encoding($str, " UTF-8", "auto"); //Unknown original encoding, after automatic detection by auto, convert the encoding to utf-8
?>

The encoding conversion function mb_convert_encoding under PHP and Instructions for use of iconv

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324579.htmlTechArticleConversion of text encoding mb_convert_encoding() mb_convert_encoding( $str, $encoding1,$encoding2 ) $str, to convert the encoding String $encoding1, target encoding, such as utf-8, gbk, both case...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn