string to character code hex string

bitwise via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 2 09:23:57 PDT 2017


On Saturday, 2 September 2017 at 15:53:25 UTC, bitwise wrote:
> [...]

This seems to work well enough.

string toAsciiHex(string str)
{
     import std.array : appender;

     auto ret = appender!string(null);
     ret.reserve(str.length * 2);
     foreach(c; str) ret.put(format!"%x"(c));
     return ret.data;
}



More information about the Digitalmars-d-learn mailing list