Base64 module

BASE64_DECODER_TABLE

constantSource

Maps each byte to what base64_decode does with it, for the standard alphabet.

A value from 0 to 63 is a symbol. 64 means skip the byte (only a line feed), 65 is the padding =, which ends the input, and 66 is invalid. Copy the table and change entries to accept other bytes:

ExampleOpen in playground ↗
table := BASE64_DECODER_TABLE;
table[#char " "] = 64;
decoded, ok := base64_decode("TW Fu", table);
defer free(decoded);
assert(ok && decoded == "Man");
BASE64_DECODER_TABLE :: #run decoder_table(BASE64_ENCODER_TABLE)

See also