https://github.com/chawyehsu/punycode.mbt
Punycode encoding and decoding in MoonBit
https://github.com/chawyehsu/punycode.mbt
moonbit
Last synced: 5 months ago
JSON representation
Punycode encoding and decoding in MoonBit
- Host: GitHub
- URL: https://github.com/chawyehsu/punycode.mbt
- Owner: chawyehsu
- License: unlicense
- Created: 2024-07-30T15:58:37.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-07T10:23:21.000Z (over 1 year ago)
- Last Synced: 2025-03-10T08:14:24.380Z (about 1 year ago)
- Topics: moonbit
- Language: MoonBit
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# punycode.mbt
> Punycode encoding and decoding in MoonBit
[![ci][ci-badge]][ci]
[![ci-daily][ci-daily-badge]][ci-daily]
[![version-svg]][mooncakes-url]
[![license][license-badge]](UNLICENSE)
## Installation
Add the library to your project as a dependency:
```sh
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.
```moonbit
@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.
```moonbit
@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.
```sh
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](https://github.com/chawyehsu). Licensed under either of the [Apache License 2.0](LICENSE-APACHE) or [The Unlicense](UNLICENSE) license at your option.
> [Blog](https://chawyehsu.com) · GitHub [@chawyehsu](https://github.com/chawyehsu) · Twitter [@chawyehsu](https://twitter.com/chawyehsu)
[ci-badge]: https://github.com/chawyehsu/punycode.mbt/workflows/CI/badge.svg
[ci-daily-badge]: https://github.com/chawyehsu/punycode.mbt/actions/workflows/daily.yml/badge.svg
[ci]: https://github.com/chawyehsu/punycode.mbt/actions/workflows/ci.yml
[ci-daily]: https://github.com/chawyehsu/punycode.mbt/actions/workflows/daily.yml
[version-svg]: https://img.shields.io/badge/mooncakes.io-v0.0.4-orange
[mooncakes-url]: https://mooncakes.io/docs/chawyehsu/punycode
[license-badge]: https://img.shields.io/github/license/chawyehsu/punycode.mbt
[moonup]: https://github.com/chawyehsu/moonup
[RFC 3492]: https://datatracker.ietf.org/doc/html/rfc3492
[punycode.c]: https://gist.github.com/chawyehsu/2792814973cdc0e9315fae7b96be38cc