V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
爱意满满的作品展示区。
dogHere

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

  •  
  •   dogHere · May 20, 2017 · 1954 views
    This topic created in 3274 days ago, the information mentioned may be changed or developed.

    写了一个类似于 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 replies    2017-05-21 00:12:05 +08:00
    v1024
        1
    v1024  
       May 20, 2017 via iPhone
    显然应该叫 iconv-cli
    dogHere
        2
    dogHere  
    OP
       May 21, 2017
    实际上已经存在了 iconv 这个命令,如果名字叫做 iconv-cli,没办法和 iconv 做区分。

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

    @v1024
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3697 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 00:39 · PVG 08:39 · LAX 17:39 · JFK 20:39
    ♥ Do have faith in what you're doing.