The OpenD Programming Language

translate

This is an overload of translate which takes an existing buffer to write the contents to.

Parameters

str C1[]

The original string.

transTable S[dchar]

The AA indicating which characters to replace and what to replace them with.

toRemove const(C2)[]

The characters to remove from the string.

buffer Buffer

An output range to write the contents to.

Examples

import std.array : appender;
dchar[dchar] transTable1 = ['e' : '5', 'o' : '7', '5': 'q'];
auto buffer = appender!(dchar[])();
translate("hello world", transTable1, null, buffer);
assert(buffer.data == "h5ll7 w7rld");

buffer.clear();
translate("hello world", transTable1, "low", buffer);
assert(buffer.data == "h5 rd");

buffer.clear();
string[dchar] transTable2 = ['e' : "5", 'o' : "orange"];
translate("hello world", transTable2, null, buffer);
assert(buffer.data == "h5llorange worangerld");

Meta