The OpenD Programming Language

Base64Impl.encoder

Construct an Encoder that iterates over the Base64 encoding of the given input range.

template Base64Impl(char Map62th, char Map63th, char Padding = '=')
Encoder!(Range)
encoder
(
Range
)
(
Range range
)
if ()

Parameters

range Range

An input range over the data to be encoded.

Return Value

Type: Encoder!(Range)

If range is a range of bytes, an Encoder that iterates over the bytes of the corresponding Base64 encoding.

If range is a range of ranges of bytes, an Encoder that iterates over the Base64 encoded strings of each element of the range.

In both cases, the returned Encoder will be a forward range if the given range is at least a forward range, otherwise it will be only an input range.

Examples

This example encodes the input one line at a time.

File f = File("text.txt", "r");
scope(exit) f.close();

uint line = 0;
foreach (encoded; Base64.encoder(f.byLine()))
{
    writeln(++line, ". ", encoded);
}

This example encodes the input data one byte at a time.

ubyte[] data = cast(ubyte[]) "0123456789";

// The ElementType of data is not aggregation type
foreach (encoded; Base64.encoder(data))
{
    writeln(encoded);
}

Meta