Test::HexDifferences::HexDump - Format binary to hexadecimal strings
0.002
use Test::HexDifferences::HexDump;
$string = hex_dump( $binary, );
$string = hex_dump( $binary, { address => $start_address, format => "%a : %4C : %d\n", } );
Every format element in the format string is starting with % like sprintf.
It is not very clever to use little-endian formats for tests. There is a fallback to bytes if multibyte formats can not displayed.
%C - unsigned char %S - unsigned 16-bit %S< - unsigned 16-bit, little-endian %S> - unsigned 16-bit, big-endian %v - unsigned 16-bit, little-endian %n - unsigned 16-bit, big-endian %L - unsigned 32-bit %L< - unsigned 32-bit, little-endian %L> - unsigned 32-bit, big-endian %V - unsigned 32-bit, little-endian %N - unsigned 32-bit, big-endian %Q - unsigned 64-bit %Q< - unsigned 64-bit, little-endian %Q> - unsigned 64-bit, big-endian
%a - 16 bit address %4a - 16 bit address %8a - 32 bit address
It can not display all chars. Fist it must be a printable ascii char. It can not be anything of space, q{.}, q{'}, q{"} or q{\}. Otherwise q{.} will be printed.
%d - display ascii
%*x - repetition endless %1x - repetition 1 time %2x - repetition 2 times ...
%\n - ignore \n
The default format is:
"%a : %4C : %d\n"
or fully written as
"%a : %4C : %d\n%*x"
The %...x allows to write mixed formats e.g.
Format: %a : %N %4C : %d\n%1x% %a : %n %2C : %d\n%*x Input: \0x01\0x23\0x45\0x67\0x89\0xAB\0xCD\0xEF \0x01\0x23\0x45\0x67 \0x89\0xAB\0xCD\0xEF Output: 0000 : 01234567 89 AB CD EF : .#-Eg... 0008 : 0123 45 67 : .#-E 000C : 89AB CD EF : g...
Inside of this Distribution is a directory named example. Run this *.t files.
This is a formatter for binary data.
$string = hex_dump( $binary, { address => $display_start_address, format => $format_string, } );
nothing
nothing
none
none
Data::Hexdumper inspired by
Steffen Winkler
Copyright (c) 2012,
Steffen Winkler
<steffenw at cpan.org>
.
All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.