encode

Encodes data and returns as an ASCII base64 string.

  1. mstring encode(ubyte[] data, mstring buff, bool pad)
    encode
    (
    in ubyte[] data
    ,,
    bool pad = true
    )
  2. mstring encode(ubyte[] data, bool pad)

Parameters

table

The encode table to use, either defaultEncodeTable (the default) or urlSafeEncodeTable, or one's own encode table. An array of 65 chars is expected, where the last char is used for padding

data ubyte[]

what is to be encoded

buff mstring

buffer large enough to hold encoded data

pad bool

Whether or not to pad the output - default to true

Examples

char[512] encodebuf;
mstring myEncodedString = encode(cast(const(ubyte)[])"Hello, how are you today?", encodebuf);
Stdout(myEncodedString).newline; // SGVsbG8sIGhvdyBhcmUgeW91IHRvZGF5Pw==

Meta