To encode, decode and check Internationalized Domain Name, it would be nice if stdlib has IDNA(Stringprep/Punycode) library like golang.org/x/net/idna and Python encodings.idna.
Wrapping libidn may be one suitable choice on Linux.
If this is to be in the standard library, it's really preferable that it be implemented in pure Nim, so that additional dependencies aren't added.
Here's a gist that does the encoding: https://gist.github.com/apense/a2e7fbddfbd0f3561b82
I just translated it from the Go punycode.go file that you linked to. Seems to work, but it's not great style. Do with it what you will.
Updated the gist. It's based of off of Libidn (both the C# and Java implementations). Tried to document what's happening It can be made a lot cleaner, but it works. Personally, I think it's not good enough for stdlib (yet, at least)
@BigBoneDaddy well the Punycode algorithm is based off an RFC, so it should be public license. I can rename some of the functions. Really, it's a bit different because Nim differentiates between len() and runelen() EDIT: different from the other implementations. I just used them as a guideline and did Nim very quickly. I'm certain there are some optimizations to be made and dirty code to be cleaned