您的位置:首页 > 运维架构 > Linux

Linux常用命令--iconv

2016-06-29 14:56 411 查看
1.功能:编码转换工具
2.安装方式:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
./configure --prefix=/usr/local
make
make install
3.语法:
iconv [OPTION...] [-f encoding] [-t encoding] [inputfile ...]
iconv -l
4.参数:
-f encoding, --from-code=encoding 起始编码
-t encoding, --to-code=encoding 输出的编码
-c 忽略非法字符
-l 列出已知的编码集合
-o 指定输出文件
-s 禁止警告信息,但不是错误信息
5.例子
测试用的文件test.txt是GBK编码,与Linux编码不一致,查看时显示乱码。使用iconv 修改编码之后显示正常。
[mysql@mysql ~]$ echo $LANG
zh_cn.UTF-8
[mysql@mysql ~]$ more test.txt

[mysql@mysql ~]$ iconv -f GBK -t UTF-8 test.txt |more
今天是星期三。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux iconv