maketrans and translate

bearophile bearophileHUGS at lycos.com
Sun Feb 12 19:04:53 PST 2012


In the online docs I've seen that std.string.maketrans() is (going to be) deprecated.
How do you adapt this code to the new regime?


import std.stdio, std.string;
void main() {
    char[] text = "dssdadsdasdas".dup; // lots of MBs of pure 7 bit ASCII text
    auto tab = maketrans("ejnqrwxdsyftamcivbkulopghzEJNQRWXDSYFTAMCIVBKULOPGHZ",
                         "0111222333445566677788899901112223334455666777888999");
    auto text2 = text.translate(tab, "\"");
    writeln(text2);
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list