punycode

    Punycode encoding and decoding in MoonBit

    encoding
    punycode
    algorithm
    idna
    Download zip
    Author
    Version
    0.0.5
    License
    Apache-2.0 OR Unlicense
    Last updated
    10 months ago
    Downloads
    34

    #punycode.mbt

    Punycode encoding and decoding in MoonBit

    #Installation

    Add the library to your project as a dependency:

    moon add chawyehsu/punycode

    #API

    ⚠️ The API is subject to change before the MoonBit language enters the mature stage.

    #punycode.encode(input: String): String?

    Encode a string of Unicode symbols to a Punycode string of ASCII-only symbols.

    @punycode.encode("bücher") // Some("bcher-kva")

    #punycode.decode(input: String): String?

    Decode a Punycode string of ASCII-only symbols to a string of Unicode symbols.

    @punycode.decode("bcher-kva") // Some("bücher")

    #Contributing

    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:

    #References

    • 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

    #License

    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

    decode

    fn decode(encoded : String) -> String?
    Converts a Punycode string of ASCII-only symbols to a string of Unicode symbols.

    encode

    fn encode(raw : String) -> String?
    Convert a string of Unicode symbols to a Punycode string of ASCII-only symbols.