最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php iconv mb_convert_encoding编码转换函数
时间:2022-06-24 23:59:25 编辑:袖梨 来源:一聚教程网
用iconv函数:
iconv( "utf-8", "gb2312" , "abc阳光123");
据说这样好些,可以忽略转换时的错误!
iconv( "utf-8", "gb2312//ignore" , "abc阳光123");
mb_convert_encoding的用法见官方:
http://*c**n.php教程.net/manual/zh/function.mb-convert-encoding.php
做一个gbk to utf-8
header("content-type: text/html; charset=utf-8");
echo mb_convert_encoding("我的友仔", "utf-8", "gbk");
?>
再来个gb2312 to big5
header("content-type: text/html; charset=big5");
echo mb_convert_encoding("你是我的朋友", "big5", "gb2312");
?>
不过要使用上面的函数需要安装但是需要先enable mbstring 扩展库。
php中的另外一个函数iconv也是用来转换字符串编码的,与上函数功能相似。
下面还有一些详细的例子:
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)
用法:
string mb_convert_encoding ( string str, string to_encoding [, mixed from_encoding] )
需要先enable mbstring 扩展库,在 php.ini里将; extension=php_mbstring.dll 前面的 ; 去掉
mb_convert_encoding 可以指定多种输入编码,它会根据内容自动识别,但是执行效率比iconv差太多;
相关文章
- 咸鱼商品被下架了怎么办 03-27
- 铁路12306官网登录入口-铁路12306官网登录失败怎么办 03-27
- 智联招聘网页版怎么登录 03-27
- 网站为什么会降权 03-27
- 啵乐腐味官方2026新版-啵乐官方漫画网页版极速下载 03-27
- 126邮箱官网免费登录入口在哪 03-27