Punycode encoding and decoding in MoonBit
Add the library to your project as a dependency:
moon add chawyehsu/punycode
Encode a string of Unicode symbols to a Punycode string of ASCII-only symbols.
@punycode.encode("bücher") // Some("bcher-kva")
Decode a Punycode string of ASCII-only symbols to a string of Unicode symbols.
@punycode.decode("bcher-kva") // Some("bücher")
The codebase might not yet be updated to support the latest version of MoonBit
language. An explicit version of the MoonBit toolchain has been pinned in the
moonbit-version
file, which is used by the moonup tool.
moonup pin toolchain-version
To contribute, it is suggested to use moonup
to manage the MoonBit toolchain:
- RFC 3492 - Punycode: A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)
- punycode.c - The original C reference implementation of Punycode in RFC 3492
punycode.mbt © Chawye Hsu. Licensed under either of the Apache License 2.0 or The Unlicense license at your option.
Blog · GitHub @chawyehsu · Twitter @chawyehsu