Translate for chars to strings
Andrej Mitrovic
andrej.mitrovich at gmail.com
Mon Mar 5 16:32:19 PST 2012
There's a really useful function 'translate' in std.string, used like this:
__gshared dchar[dchar] MangleTable;
shared static this()
{
MangleTable =
[
'*':'p', // ptr
'&':'r', // reference
'<':'L', // left angle
'>':'R', // right angle
' ':'_', // space
];
}
string mangleType(string input)
{
return input.translate(MangleTable);
}
However I'm looking for something which translates characters to
strings. Of course that also implies potential reallocation. Does
anyone have such a function in some library?
Note that I'm not looking for .mangleof, I need to work on strings of
C++ names, not D symbols.
More information about the Digitalmars-d-learn
mailing list