base16/base32/base36/base58/base62/base64 for MoonBit — RFC 4648 hex/base32/base64 plus a big-integer base-N core behind base36/base58/base62.
| Package | What it is | Kind |
|---|---|---|
| @base16 | RFC 4648 hexadecimal | byte-oriented (2 chars/byte) |
| @base32 | RFC 4648 A-Z2-7 + base32hex 0-9A-V | byte-oriented (5 bytes → 8 chars) |
| @base36 | dense case-insensitive 0-9a-z, plus an integer mode | big-integer base-N |
| @base58 | the Bitcoin / IPFS alphabet (0OIl dropped) | big-integer base-N |
| @base62 | URL-safe 0-9A-Za-z, plus an integer mode | big-integer base-N |
| @base64 | RFC 4648 standard +/ and URL-safe -_ | byte-oriented (3 bytes → 4 chars) |
moon add Lfan-ke/basex@base16.encode(b"\x00\x0f\xff") // -> "000fff" (leading zero survives)
@base16.encode_upper(b"foobar") // -> "666F6F626172" (RFC 4648 canonical)
@base16.decode("DeAdBeEf") // -> Some(b"\xde\xad\xbe\xef")
@base16.decode("abc") // -> None (odd length)@base32.encode(b"foobar") // -> "MZXW6YTBOI======"
@base32.decode("MZXW6YTBOI") // -> Some(b"foobar") (padding optional)
@base32.encode_hex(b"foobar") // -> "CPNMUOJ1E8======"
@base32.decode_hex("CPNMUOJ1E8======") // -> Some(b"foobar")@base36.encode(b"\xde\xad\xbe\xef") // bytes -> a base36 string
@base36.decode("...") // string -> Some(bytes) / None
@base36.encode_uint(123456789) // -> "21i3v9" (== (123456789).toString(36))
@base36.decode_uint("21i3v9") // -> Some(123456789)let encoded = @base58.encode(b"Hello, MoonBit!")
let decoded = @base58.decode(encoded) // -> Some(b"Hello, MoonBit!")
@base58.decode("0OIl") // -> None (none of these are base58 characters)@base62.encode(b"\xde\xad\xbe\xef") // bytes -> a base62 string
@base62.decode("...") // string -> Some(bytes) / None
@base62.encode_uint(123456789) // -> "8M0kX"
@base62.decode_uint("8M0kX") // -> Some(123456789)@base64.encode(b"foobar") // -> "Zm9vYmFy"
@base64.encode(b"f") // -> "Zg=="
@base64.decode("Zm9vYg") // -> Some(b"foob") (padding optional)
@base64.encode_url(b"\xfb\xff\xbf") // -> "-_-_" (never + / or =)
@base64.decode_url("-_-_") // -> Some(b"\xfb\xff\xbf")let base36 = @basex.Alphabet::new("0123456789abcdefghijklmnopqrstuvwxyz")
@basex.encode(b"\xde\xad\xbe\xef", base36) // -> a base36 string
@basex.decode("...", base36) // -> Some(bytes) / Nonemoon testbase16/base32/base36/base58/base62/base64 for MoonBit — RFC 4648 hex/base32/base64 plus a big-integer base-N core behind base36/base58/base62.