makeTransTable

Construct 256 character translation table, where characters in from[] are replaced by corresponding characters in to[].

@safe pure nothrow @nogc
char[256]
makeTransTable
(
scope const(char)[] from
,
scope const(char)[] to
)

Parameters

from const(char)[]

array of chars, less than or equal to 256 in length

to const(char)[]

corresponding array of chars to translate to

Return Value

Type: char[256]

translation array

Examples

assert(translate("hello world", makeTransTable("hl", "q5")) == "qe55o wor5d");
assert(translate("hello world", makeTransTable("12345", "67890")) == "hello world");

Meta