decode

Decodes an ASCCI base64 string and returns it as ubyte[] data.

This decoder will ignore non-base64 characters, so for example data with newline in it is valid. Note that the entries in the provided decode table are not required to be unique. This allows the use of decode tables with alternatives for certain characters.

Since the padding is required only between multiple base64 strings (for the decoder not to interpret the start of the next string as the end of the previous one), data may or may not contain the trailing padding, and it will still be decoded correctly.

Parameters

data cstring

what is to be decoded

buff ubyte[]

a big enough array to hold the decoded data

Examples

ubyte[512] decodebuf;
mstring myDecodedString = cast(mstring)decode("SGVsbG8sIGhvdyBhcmUgeW91IHRvZGF5Pw==", decodebuf);
Stdout(myDecodedString).newline; // Hello, how are you today?

Meta