#domain-name #idna #ascii #unicode #codec #arguments #to-from

bin+lib idna-cli

将 Unicode 域名编码/解码为/从 IDNA ASCII

7 个版本

0.1.6 2024 年 8 月 16 日
0.1.5 2024 年 7 月 23 日
0.1.4 2023 年 8 月 21 日

#594文本处理

Download history 107/week @ 2024-07-20 34/week @ 2024-07-27

每月 141 次下载

MIT 许可证

11KB
180 代码行

关于

将 Unicode 域名编码/解码为/从 IDNA ASCII

使用方法

$ idna -h
Encode/decode Unicode domain names to/from IDNA ASCII

Usage: idna [OPTIONS] [DOMAINS]...

Arguments:
  [DOMAINS]...  One or more domains

Options:
  -d, --decode           Decode IDNA ASCII input to Unicode
  -f, --files <FILES>    One or more files
  -o, --output <FORMAT>  Output format (csv, json, json-pretty, rust,
                         rust-pretty) [default: csv]
  -h, --help             Print help
  -V, --version          Print version
$ idna -V
idna 0.1.6

示例

编码

$ idna goögle.com
"Unicode","ASCII","Errors"
"goögle.com","xn--gogle-kua.com",""

解码

$ idna -d xn--gogle-kua.com
"ASCII","Unicode","Errors"
"xn--gogle-kua.com","goögle.com",""

文件

$ idna -f unicode.txt
"Unicode","ASCII","Errors"
"goögle.com","xn--gogle-kua.com",""
$ idna -df ascii.txt
"ASCII","Unicode","Errors"
"xn--gogle-kua.com","goögle.com",""

JSON 输出

$ idna goögle.com -o json
{"Arguments":{"goögle.com":{"ascii":"xn--gogle-kua.com","unicode":"goögle.com","errors":""}}}
$ idna -d xn--gogle-kua.com -o json
{"Arguments":{"xn--gogle-kua.com":{"ascii":"xn--gogle-kua.com","unicode":"goögle.com","errors":""}}}
$ idna goögle.com -o json-pretty
{
  "Arguments": {
    "goögle.com": {
      "ascii": "xn--gogle-kua.com",
      "unicode": "goögle.com",
      "errors": ""
    }
  }
}
$ idna -d xn--gogle-kua.com -o json-pretty
{
  "Arguments": {
    "xn--gogle-kua.com": {
      "ascii": "xn--gogle-kua.com",
      "unicode": "goögle.com",
      "errors": ""
    }
  }
}

文件到 JSON

$ idna -f unicode.txt -o json
{"File: \"unicode.txt\"":{"goögle.com":{"ascii":"xn--gogle-kua.com","unicode":"goögle.com","errors":""}}}
$ idna -df ascii.txt -o json
{"File: \"ascii.txt\"":{"xn--gogle-kua.com":{"ascii":"xn--gogle-kua.com","unicode":"goögle.com","errors":""}}}
$ idna -f unicode.txt -o json-pretty
{
  "File: \"unicode.txt\"": {
    "goögle.com": {
      "ascii": "xn--gogle-kua.com",
      "unicode": "goögle.com",
      "errors": ""
    }
  }
}
$ idna -df ascii.txt -o json-pretty
{
  "File: \"ascii.txt\"": {
    "xn--gogle-kua.com": {
      "ascii": "xn--gogle-kua.com",
      "unicode": "goögle.com",
      "errors": ""
    }
  }
}

依赖项

~6–19MB
~220K SLoC