The OpenD Programming Language

Base64Impl.encode

Encodes source into an output range using Base64 encoding.

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

Parameters

source R1

The input range to encode.

range R2

The output range to store the encoded result.

Return Value

Type: size_t

The number of times the output range's put method was invoked.

Examples

import std.array : appender;

auto output = appender!string();
ubyte[] data = [0x1a, 0x2b, 0x3c, 0x4d, 0x5d, 0x6e];

// This overload of encode() returns the number of calls to the output
// range's put method.
assert(Base64.encode(data, output) == 8);
assert(output.data == "Gis8TV1u");

Meta