base64Decode

base64Decode converts base64 to ascii. But there are choices about what to do with illegal characters or malformed strings. In this version there is a strict flag to indicate that the input must be a single valid base64 string with no illegal characters, no extra padding, and no short segments. Otherwise there is best effort to decode around illegal characters which ARE preserved in the output. So "TWFyeQ==.aGFk.YQ.bGl0dGxl.bGFtYg==" decodes to "Mary.had.a.little.lamb" with five seperate base64 strings decoded, each separated by the illegal character dot. In strict mode the first dot would trigger a fatal error. Some other implementations choose to ignore illegal characters which of course has it's own issues. The four whitespace characters <CR> <LF> <TAB> and <SPACE> are silently ignored unless noWhitespaceFlag is set. In this case whitespace is treated similar to illegal characters and base64 decoding operates around the white space. So "TWFyeQ== aGFk YQ bGl0dGxl bGFtYg==" would decode as "Mary had a little lamb". Decoding is done by loading four base64 characters at a time into a bitField, and then extracting them as three ascii characters. returnString is assumed to be large enough to contain the result (which could be the same size as the input), and the function return is the length of the result, or a negative value in case of an error

pure nothrow @safe @nogc
int
base64Decode
(
ref char[] resultString
,
const char[] encodedString
,,,)

Meta