punycode

command module
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 7 Imported by: 0

README

punycode

Go Report Coverage Status

A simple CLI tool to decode a punycode encoded string

Usage

Decoding a single string, meaning conversion from punycode to human readable text
punycode xn--blbrgrd-fxak7p

Will emit

blåbærgrød

As an alternative to provided arguments, you can pipe text into punycode

echo xn--blbrgrd-fxak7p | punycode

Will emit

blåbærgrød
Encoding a single string, meaning conversion from human readable text to punycode
punycode kødpålæg

Will emit

xn--kdplg-orai3l

As an alternative to provided arguments, you can pipe text into punycode

echo kødpålæg | punycode

Will emit

xn--kdplg-orai3l

Installation

Installation is easy using Go

go install github.com/jonasbn/punycode@latest

If you want a particular version, please see Go Modules Reference

Description

TODO

Diagnostics

TODO

Exit Status

  • 0 success, provided string has been decoded and printed

  • 1 failure no argument provided or data from STDIN

  • 2 failure reading from STDIN

  • 3 encoding or decoding failed

Dependencies

This utility requires:

In addition to a few of the standard libraries

Bugs and Limitations

There a no known bugs, please see the GitHub repository issues section for a up to date listing.

Only support for Unicode

The utility is limited to decoding to Unicode (version 13) from Punycode.

Please see golang.org/x/net/idna for details.

Only a single argument

punycode only takes a single argument.

punycode xn--blbrgrd-fxak7p
blåbærgrød

So providing more than one argument will only return the first argument

punycode xn--blbrgrd-fxak7p xn--kdplg-orai3l
blåbærgrød

Author

  • jonasbn

Acknowledgements

  • @isviridov, bug fix contribution

Motivation

This utility was created, when in the process of learning Go. I have worked in the DNS and domain name business for a decade so it was only natural to work on something I know when learning Go.

This particular repository touched the following topics:

  1. Learning to make CLI tools
  2. Making an executable distributable and installable component
  3. Reading data from the CLI
  4. Reading data from STDIN
  5. Testing a CLI tool / Main function in Go

All of the above was covered in: punyencode and punydecode

The punycode is a merge of the two, which then opened up for more things to learn.

  1. Using a regular expressions
  2. Capturing and testing output emitted to STDOUT

See the resources and references below for resources on the above topics.

Resources and References

  1. Wikipedia: Punycode
  2. Go Modules Reference
  3. GitHub: punydecode
  4. GitHub: punyencode
  5. golang.org/x/net/idna
  6. Go By Example: Regular Expressions
  7. yourbasic.org/golang: Read a file (stdin) line by line
  8. Blog post: Test the main function in Go by Johannes Malsam
  9. StackOverflow: "In Go, how do I capture stdout of a function into a string?"
  10. StackOverflow: "How to test a function's output (stdout/stderr) in unit tests"

Copyright Jonas Brømsø (jonasbn) 2022-2023

MIT License, see separate LICENSE file

Documentation

Overview

punycode is a utility to encode and decode to and from punycode on the command line

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL