Logo

Programming-Idioms

History of Idiom 176 > diff from v9 to v10

Edit summary for version 10 by cym13:
New D implementation by user [cym13]

Version 9

2019-03-19, 16:32:07

Version 10

2019-03-19, 16:44:16

Idiom #176 Hex string to byte array

From hex string s of 2n digits, build the equivalent array a of n bytes.
Each pair of hexadecimal characters (16 possible values per digit) is decoded into one byte (256 possible values).

Idiom #176 Hex string to byte array

From hex string s of 2n digits, build the equivalent array a of n bytes.
Each pair of hexadecimal characters (16 possible values per digit) is decoded into one byte (256 possible values).

Extra Keywords
hexa
Extra Keywords
hexa
Imports
import std.conv;
import std.string;
Code
ubyte[] a = cast(ubyte[]) hexString!s.representation;
Comments bubble
hexString can be used if s is known at compile time.
Doc URL
https://dlang.org/phobos/std_conv.html#.hexString