I've been reading std.conv and std.range, trying to figure out a high-level way of converting a hex string to bytes. The only way I've been able to do it is through pointer access:

import std.stdio;
import std.string;
import std.conv;

void main()
{
    immutable char* hex = "deadbeef".toStringz;
    for (auto i=0; hex[i]; i += 2)
        writeln(to!byte(hex[i]));
}


While it works, I'm wondering if there is a more object-oriented way of doing it in D.

Reply via email to