The OpenD Programming Language

Base64Impl.decode

Decodes source into the given buffer.

  1. ubyte[] decode(R1 source, R2 buffer)
  2. ubyte[] decode(R1 source, R2 buffer)
    template Base64Impl(char Map62th, char Map63th, char Padding = '=')
    ubyte[]
    decode
    (
    R1
    R2
    )
    (,)
    if (
    !isArray!R1 &&
    &&
    is(ElementType!R1 : dchar)
    &&
    &&
    is(R2 == ubyte[])
    &&
    isOutputRange!(R2, ubyte)
    )
  3. size_t decode(R1 source, R2 range)
  4. size_t decode(R1 source, R2 range)
  5. ubyte[] decode(Range source)
  6. ubyte[] decode(Range source)

Parameters

source R1

The input range to decode.

buffer R2

The buffer to store decoded result.

Return Value

Type: ubyte[]

The slice of buffer containing the decoded result.

Throws

Base64Exception if source contains characters outside the base alphabet of the current Base64 encoding scheme.

Examples

auto encoded = "Gis8TV1u";
ubyte[32] buffer;   // much bigger than necessary

// Just to be sure...
auto decodedLength = Base64.decodeLength(encoded.length);
assert(buffer.length >= decodedLength);

// decode() returns a slice of the given buffer.
auto decoded = Base64.decode(encoded, buffer[]);
assert(decoded is buffer[0 .. decodedLength]);
assert(decoded == [0x1a, 0x2b, 0x3c, 0x4d, 0x5d, 0x6e]);

Meta