linux iconv命令详解,iconv命令

iconv命令:

Convert encoding of given files from one encoding to another,更改文件的编码格式

语法格式:

iconv -f encoding -t encoding inputfile

常用选项:

-f encoding :把字符从encoding编码开始转换

-t encoding :把字符转换到encoding编码

-l 列出已知的编码字符集合

-o file :指定输出文件

-c :忽略输出的非法字符

-s :禁止警告信息,但不是错误信息

实例:[root@www1 ~]# iconv test.txt -f UTF-8 -t gbk

▒▒һ▒▒

▒ڶ▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

You have mail in /var/spool/mail/root

[root@www1 ~]# iconv test.txt -c -f UTF-8 -t gbk

▒▒һ▒▒

▒ڶ▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

[root@www1 ~]# iconv test.txt -c -f UTF-8 -t gbk -o testt.txt

You have mail in /var/spool/mail/root

[root@www1 ~]# cat testt.txt

▒▒һ▒▒

▒ڶ▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

▒▒▒▒▒▒

[root@www ~]# cat dos2.txt

▒▒▒▒▒ٶȿ▒▒▒▒▒▒ٶȿ▒▒▒

▒▒▒▒▒޻▒Ʒ▒▒˹▒ƴ▒▒▒

▒ռ▒▒▒▒Ƽ▒▒▒ʦ▒▒

▒ռ▒▒ط▒▒▒▒ʱ▒▒η▒▒ʢ

[root@www ~]# iconv dos21.txt -f gbk -t UTF-8

发了速度快解放了速度快解放

放声大哭会计法拉斯科大姐夫

空间大福利科技大师傅

收集地方拉卡时间段法拉盛

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值