linux下使用iconv命令转换gbk编码为UTF-8编码

1. 通过iconv -l 命令查看,其支持的编码格式还不少,之间可以互相转换

2. 转换gbk编码文件为utf-8编码文件

简洁命令:iconv  -f gbk -t utf-8 index.html > aautf8.html

其中-f指的是原始文件编码,-t是输出编码  index.html 是原始文件   aautf8.html是输出结果文件

3. 转换gbk编码文件为utf-8编码文件

详细命令:iconv -c --verbose  -f gbk -t utf-8 index.html -o index_utf8.html

-c 指的是从输出中忽略无效的字符, --verbose指的是打印进度信息   -o是输出文件

4. 转换utf-8编码文件为gb2312编码文件

详细命令:iconv -c --verbose  -f utf-8 -t gb2312 index_utf8.html -o index_gb2312.html

5. php中iconv函数使用方法,iconv函数库能够完成各种字符集间的转换,是php编程中不可缺少的基础函数库

1.首先下载libiconv函数库

2、解压缩tar -zxvf libiconv-1.9.2.tar.gz

3、安装libiconv        configure --prefix=/usr/local/iconv        make        make install 4、重新编译php 增加编译参数--with-iconv=/usr/local/iconv 

结果:iconv被安装到/usr/local/目录中




猜你喜欢

转载自blog.csdn.net/konglongaa/article/details/80590843
今日推荐