iconv脚本
来源:互联网 发布:淘宝开店装修 编辑:程序博客网 时间:2024/06/05 19:28
#!/bin/bash
#encode.sh -- encode a file with an indicated encoding
# make sure user give two arguments
[ "$#" != 2 ] && echo "Usage: `basename $0` [to_encoding] [file]" && exit -1
# make sure the second argument is a regular file
[ ! -f $2 ] && echo "the second argument should be a regular file " && exit 1
file=$2
# make sure the first argument is a encoding supported by iconv
iconv -l | grep -q $1
[ $? -ne 0 ] && echo "iconv not support such encoding: $1" && exit -1
to_encoding=$1
# is there a text file?
file_type=`file $file | grep "text"`
[ $? -ne 0 ] && echo "$file is not a text file" && exit -1
# get the old encoding
from_encoding=`echo $file_type | cut -d" " -f 2`
from_encoding=`iconv -l | grep $from_encoding`
[ $? -ne 0 ] && echo "iconv not support the old encoding: $from_encoding"
from_encoding=`echo $from_encoding | cut -d"/" -f 1`
# convert the file from from_encoding to to_encoding
iconv -f $from_encoding -t $to_encoding $file
- iconv脚本
- iconv的转化脚本
- linux iconv 文件编码转换脚本
- iconv
- iconv
- iconv
- iconv
- iconv
- iconv
- iconv
- iconv
- [mark]关于php iconv()脚本中断的问题
- shell脚本中使用iconv实现批量文件转码
- shell脚本中使用iconv批量改变文件编码
- 乱码 iconv
- iconv 使用
- Text::iconv
- iconv 命令
- 【Storm总结-4】Storm 中acker的工作流程
- 11.11这一天我将怎么过(男人篇)
- jQuery获取Select option 选择的Text和Value
- EndDialog 与 DestroyWindow 的区别
- NSLog
- iconv脚本
- Freemarker调用java静态方法(也可以调用常量,枚举)
- hibernate标签 property-ref 属性
- Hibernate一对多示例
- 【Storm总结-5】Twitter Storm: Transactional Topolgoy简介
- 第十一周 项目6:回文素数(2)
- 明白了为啥样式前面老是加 -webkit-、-moz-等
- python推数据及流处理扩展
- Highcharts js统计图插件