Darren:

Let's say I have a hex representation of a large number:

String hexnum = "16D81B16E091F31BEF";

I'd like to convert it into a ubyte[]

A simple way is to use hex strings and then cast it to immutable(ubyte)[]:

void main() {
immutable hexNum = cast(immutable(ubyte)[])x"16D81B16E091F31BEF";
}

The immutable at the cast point is needed because string literals are immutable in D. If you need a mutable ubyte[] you need a dup.

Also vote here:
https://issues.dlang.org/show_bug.cgi?id=5909

Bye,
bearophile

Reply via email to