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

bin+lib idna-cli

Encode/decode Unicode domain names to/from IDNA ASCII

9 releases

0.2.1 Dec 4, 2024
0.2.0 Oct 24, 2024
0.1.6 Aug 16, 2024
0.1.5 Jul 23, 2024
0.1.4 Aug 21, 2023

#1099 in Text processing

Download history 11/week @ 2024-09-14 7/week @ 2024-09-21 6/week @ 2024-09-28 101/week @ 2024-10-19 24/week @ 2024-10-26 5/week @ 2024-11-02 1/week @ 2024-11-16 109/week @ 2024-11-30 45/week @ 2024-12-07

156 downloads per month

MIT license

11KB
188 lines

About

Encode/decode Unicode domain names to/from IDNA ASCII

Usage

$ 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.2.1

Examples

Encode

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

Decode

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

Files

$ 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 output

$ 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": ""
    }
  }
}

Files to 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": ""
    }
  }
}

Dependencies

~5–15MB
~205K SLoC