std/text/encoding
std/encoding — text-friendly serializations of byte data, in pure
Axle. Hex is fixed-format (lowercase, no spaces). Base64 follows
RFC 4648: the standard alphabet (+/) with = padding, and a
URL-safe variant (-_, no padding).
Operates on string carrying UTF-8 bytes — the "encode this text"
/ "decode this token back to text" path. Encoders read the input's
raw bytes (byteAt) and emit pure-ASCII output. Decoders rebuild
the original bytes into a scratch buffer and validate them as UTF-8
before materialising a string; a malformed encoding or non-UTF-8
result raises ParseException, never a silently-corrupted value.
Free functions
| Type | Method and description |
|---|---|
| __b64Char(symbol : i32, urlSafe : bool) : i32 Base64 alphabet character (ASCII) for a 6-bit symbol 0..63.urlSafe selects -_ for 62/63 instead of +/. |
| __b64Symbol(ch : i32, urlSafe : bool) : i32 6-bit symbol value 0..63 for a base64 alphabet byte, or -1 if the byte is not in the selected alphabet. |
| hexEncode(s : string) : string Lowercase, fixed-width hex of the input's bytes ("hi" → "6869"). |
| hexDecode(s : string) : string Inverse of [hexEncode]. Raises ParseException on an odd length,a non-hex digit, or bytes that do not form valid UTF-8. |
| __b64Encode(s : string, urlSafe : bool) : string Encode the input's bytes as base64. urlSafe picks the -_alphabet and drops = padding (the standard form uses +/ andpads to a multiple of four characters). |
| __b64Decode(s : string, urlSafe : bool) : string Decode base64 (either alphabet via urlSafe). Whitespace and =padding are ignored; any other out-of-alphabet byte, a dangling single symbol, or non-UTF-8 output raises ParseException. |
| base64Encode(s : string) : string Standard RFC 4648 base64 (+/ alphabet, = padding). |
| base64Decode(s : string) : string Inverse of [base64Encode]. Whitespace and = padding are ignored;an out-of-alphabet byte, a dangling symbol, or non-UTF-8 output raises ParseException. |
| base64UrlEncode(s : string) : string URL-safe variant (-_ instead of +/, no padding). |
| base64UrlDecode(s : string) : string Inverse of [base64UrlEncode] (the -_ alphabet). Same validationas [ base64Decode]; padding, if present, is still tolerated. |
Method detail
#__b64Char
Base64 alphabet character (ASCII) for a 6-bit symbol 0..63.urlSafe selects -_ for 62/63 instead of +/.
symbol 6-bit symbol value, 0..63urlSafe use the -_ URL-safe alphabet instead of +/#__b64Symbol
6-bit symbol value 0..63 for a base64 alphabet byte, or -1 if the
byte is not in the selected alphabet.
ch candidate alphabet byte (ASCII code point)urlSafe decode against the -_ URL-safe alphabet instead of +/#hexEncode
Lowercase, fixed-width hex of the input's bytes ("hi" → "6869").
s text whose raw UTF-8 bytes are hex-encoded#hexDecode
Inverse of [hexEncode]. Raises ParseException on an odd length,
a non-hex digit, or bytes that do not form valid UTF-8.
s even-length lowercase/uppercase hex text to decode#__b64Encode
Encode the input's bytes as base64. urlSafe picks the -_
alphabet and drops = padding (the standard form uses +/ and
pads to a multiple of four characters).
s text whose raw UTF-8 bytes are encodedurlSafe use the -_ alphabet and omit = padding#__b64Decode
Decode base64 (either alphabet via urlSafe). Whitespace and =
padding are ignored; any other out-of-alphabet byte, a dangling
single symbol, or non-UTF-8 output raises ParseException.
s base64 text to decodeurlSafe decode against the -_ URL-safe alphabet instead of +/#base64Encode
Standard RFC 4648 base64 (+/ alphabet, = padding).
s text whose raw UTF-8 bytes are encoded#base64Decode
Inverse of [base64Encode]. Whitespace and = padding are ignored;
an out-of-alphabet byte, a dangling symbol, or non-UTF-8 output
raises ParseException.
s standard-alphabet base64 text to decode#base64UrlEncode
URL-safe variant (-_ instead of +/, no padding).
s text whose raw UTF-8 bytes are encoded#base64UrlDecode
Inverse of [base64UrlEncode] (the -_ alphabet). Same validation
as [base64Decode]; padding, if present, is still tolerated.
s URL-safe-alphabet base64 text to decode