more OO way to do hex string to bytes conversion
Ralph Doncaster
nerdralph at github.com
Tue Feb 6 18:33:02 UTC 2018
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.
More information about the Digitalmars-d-learn
mailing list