Base64Impl.decodeLength

Given a Base64 encoded string, calculates the length of the decoded string.

template Base64Impl(char Map62th, char Map63th, char Padding = '=')
@safe pure @nogc nothrow
size_t
decodeLength
(
in size_t sourceLength
)

Parameters

sourceLength size_t

The length of the Base64 encoding.

Return Value

Type: size_t

The length of the decoded string corresponding to a Base64 encoding of length sourceLength.

Examples

auto encoded = "Gis8TV1u";

// Allocate a sufficiently large buffer to hold to decoded result.
auto buffer = new ubyte[Base64.decodeLength(encoded.length)];

Base64.decode(encoded, buffer);
assert(buffer == [0x1a, 0x2b, 0x3c, 0x4d, 0x5d, 0x6e]);

Meta