PHP文字编码的转换mb_convert_encoding()

文字编码的转换mb_convert_encoding()

mb_convert_encoding( $str, $encoding1,$encoding2 )

$str,要转换编码的字符串
$encoding1,目标编码,如utf-8,gbk,大小写均可
$encoding2,原编码,如utf-8,gbk,大小写均可

实例1

<?php   
$str='电影618:http://www.movie618.com';
echo mb_convert_encoding($str, "UTF-8"); //编码转换为utf-8
?>
<?php   
$str='电影618:http://www.movie618.com';
echo mb_convert_encoding($str, "UTF-8", "GBK"); //已知原编码为GBK,转换为utf-8
?>


<?php   
$str='电影618:http://www.movie618.com';
echo mb_convert_encoding($str, "UTF-8", "auto"); //未知原编码,通过auto自动检测后,换编码为utf-8
?>


posted @ 2011-11-09 07:25  飞天神鼠  阅读(684)  评论(1编辑  收藏  举报