Class Base64Options
BASE64_ENCODE takes up to three: the value, a MAX LINE LENGTH that wraps the encoded
text, and an ALPHABET whose two characters stand in for the standard + and /. The
decoders take the alphabet as their second argument so a custom encoding can be read back —
BASE64_DECODE_BINARY(BASE64_ENCODE(b, 0, '$%'), '$%') round-trips, while decoding the same
text with the standard alphabet is an error, because $ and % are not base64.
A line length of 0 means no wrapping, which is the default. Wrapping inserts a newline every N characters with none left trailing, so a 14-group encoding at width 8 carries 13 newlines.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringalphabetOf(List<Object> args, int index) The alphabet argument atindex, or the standard+/when it is not given.static intlineLengthOf(List<Object> args, int index) The max-line-length argument atindex, or 0 — no wrapping — when it is not given.static RuntimeExceptionThe refusal for text that is not base64 once its alphabet has been normalised.static StringtoCustomAlphabet(String standard, String alphabet) Standard base64 output rewritten into the caller's alphabet.static StringtoStandardAlphabet(String text, String alphabet) The caller's alphabet rewritten back to standard base64, ready to decode.static StringThe encoded text broken into lines ofmaxLineLength, or unchanged when that is 0.
-
Method Details
-
alphabetOf
The alphabet argument atindex, or the standard+/when it is not given. -
lineLengthOf
The max-line-length argument atindex, or 0 — no wrapping — when it is not given.A fractional length is ROUNDED rather than truncated, half away from zero, which is visible in the output: a length of 8.7 wraps at NINE characters and one of 1.5 at two. Anything that rounds to zero or below wraps nothing — a negative length reaching this point is not an error, it is no wrapping. A length that does not fit a 32-bit integer IS an error, and live names the ROUNDED value in it.
The compile-time half of the rule lives in the expression walk, which refuses an integral numeric LITERAL outside
[0, 2147483647]before a row is read. The halves do not overlap: such a literal never reaches here, and everything else is only ever judged here. -
toCustomAlphabet
Standard base64 output rewritten into the caller's alphabet. -
toStandardAlphabet
The caller's alphabet rewritten back to standard base64, ready to decode. -
wrap
The encoded text broken into lines ofmaxLineLength, or unchanged when that is 0. -
notBase64
The refusal for text that is not base64 once its alphabet has been normalised.
-