init
A bunch of assertions, then simply pass the data right through.
Function parameters
Parameters
- alphabet_chars:[64]u8
- pad_char:?u8
Base64 codecs
Types
- Codecs
- Base64 codecs
Error sets in this namespace
Error Sets
The Base64 alphabet defined in
Values
- standard_alphabet_chars
- The Base64 alphabet defined in
- standard
- Standard Base64 codecs, with padding, as defined in
- standard_no_pad
- Standard Base64 codecs, without padding, as defined in
- url_safe_alphabet_chars
- The URL-safe Base64 alphabet defined in
- url_safe
- URL-safe Base64 codecs, with padding, as defined in
- url_safe_no_pad
- URL-safe Base64 codecs, without padding, as defined in
Source
Implementation
pub fn init(alphabet_chars: [64]u8, pad_char: ?u8) Base64Encoder {
assert(alphabet_chars.len == 64);
var char_in_alphabet = [_]bool{false} ** 256;
for (alphabet_chars) |c| {
assert(!char_in_alphabet[c]);
assert(pad_char == null or c != pad_char.?);
char_in_alphabet[c] = true;
}
return Base64Encoder{
.alphabet_chars = alphabet_chars,
.pad_char = pad_char,
};
}