An implementation of Punycode as described by RFC3492 in PureScript.
In addition to encoding/decoding arbitrary punycode, it also implements toASCII
and toUnicode
from
RFC3490
for the special cases of domain names and email addresses.
spago install punycode
The API is quite simple:
encode "my unicode string"
decode "my ascii string"
toUnicode "example.com"
toASCII "example.com"
All functions return an Either Error String
, so you can handle
cases where the input fails to encode/decode. There are no
side effects.
This was influenced by the implementation in punycode.js in addition to the pseudocode from the RFC.