V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
dogHere
V2EX  ›  分享创造

iconv-super 解决字符编码的转码问题-自动探测,文件夹转换

  •  
  •   dogHere · 2017-05-20 16:32:24 +08:00 · 1573 次点击
    这是一个创建于 2525 天前的主题,其中的信息可能已经有所发展或是发生改变。

    写了一个类似于 iconv 的字符转码软件,基本功能和它一样,另外支持自动探测编码格式,文件夹转换的功能。

    举几个例子:

    把一个文件(夹)里面的所有内容,从 big5 转到 utf-8:

    ./iconv-super -f big5 -t utf-8 -s math -d math-converted
    

    -c,同时把非 big5 的文件 copy 到另一个文件夹:

    ./iconv-super -f big5 -t utf-8 -s math -d math-converted -c
    

    -n,非 big5 的文件 copy 到另一个文件夹,但不转换 big5 文件:

    ./iconv-super -f big5 -t utf-8 -s math -d math-converted -c -n
    

    -c,显示 log:

    ./iconv-super -f big5 -t utf-8 -s math -d math-converted -v
    

    -r,正则匹配特定文件:

    ./iconv-super -f big5 -t utf-8 -s math -d math-converted -r .html
    

    去掉-f,自动探测源文件编码:

    ./iconv-super -t utf-8 -s math -d math-converted
    

    用管道:

    cat file |./iconv-super -f big5 -t utf-8 
    

    用管道,同时自动探测:

    cat file |./iconv-super  -t utf-8 
    

    项目地址:iconv-super.

    如有变更,项目地址为准。

    2 条回复    2017-05-21 00:12:05 +08:00
    v1024
        1
    v1024  
       2017-05-20 18:18:19 +08:00 via iPhone
    显然应该叫 iconv-cli
    dogHere
        2
    dogHere  
    OP
       2017-05-21 00:12:05 +08:00
    实际上已经存在了 iconv 这个命令,如果名字叫做 iconv-cli,没办法和 iconv 做区分。

    本项目和 iconv 的区别在于,自动探测源文件编码,批量处理文件夹(比如文件夹中有各种编码的文件,还有音乐,视频等以及其他二进制文件,可以只转换需要转换的文本,选择性复制没有转换的文件,你很难写一个 bash 脚步结合 iconv 实现本功能),因此,本工具的能力是在 iconv 之上,叫 iconv-super 合情合理。

    @v1024
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3570 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 04:38 · PVG 12:38 · LAX 21:38 · JFK 00:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.