Function toPrettyHexDump
Converts the given array of type T
to a hex dump string.
After a configurable number of bytes of hexadecimal numbers, the same bytes are shown as characters,
or '.' if not printable. This similar to the hexdump
CLI command.
string toPrettyHexDump(T)
(
const T[] edata,
size_t offset = 0,
string prefix = "",
const int chunksize = 16
);
Parameters
Name | Description |
---|---|
edata | The array of T to be dumped as hex. |
offset | Instead of 0 use some other start value for the dump |
prefix | Prefix to output. The default is an empty string. |
chunksize | Number of bytes per line. The default is 16. |
Returns
A string representing the hex dump of the input data.
Example
ubyte[] exampleData = cast(ubyte[])"This is an example of a hex dump function in D.\n"; string dump = toPrettyHexDump(exampleData); writeln(dump);