README
1NAME
2 String::Dump - Dump strings of characters (or bytes) for printing and
3 debugging
4
5VERSION
6 This document describes String::Dump version 0.09.
7
8SYNOPSIS
9 use String::Dump qw( dump_hex dump_bin );
10
11 say 'hex: ', dump_hex($string);
12 say 'bin: ', dump_bin($string);
13
14DESCRIPTION
15 When debugging or examining strings containing non-ASCII or non-printing
16 characters, String::Dump is your friend. It provides simple functions to
17 return a dump of the code points for Unicode strings or the bytes for
18 byte strings in several different formats, such as hex, binary, Unicode
19 names, and more.
20
21 For using this module from the command line, see the bundled dumpstr
22 script. For tips on debugging Unicode or byte strings with this module,
23 see the document String::Dump::Debugging.
24
25FUNCTIONS
26 These functions all accept a single argument: the string to dump, which
27 may either be a Unicode string or a byte string. All functions are
28 exported by default unless specific ones are requested. The ":all" tag
29 may be used to explicitly export all functions.
30
31 dump_hex($string)
32 Hexadecimal (base 16) mode.
33
34 use utf8;
35 # string of 6 characters
36 say dump_hex('Ĝis! ☺'); # 11C 69 73 21 20 263A
37
38 no utf8;
39 # series of 9 bytes
40 say dump_hex('Ĝis! ☺'); # C4 9C 69 73 21 20 E2 98 BA
41
42 For a lowercase hex dump, simply pass the response to "lc".
43
44 say lc dump_hex('Ĝis! ☺'); # 11c 69 73 21 20 263a
45
46 dump_dec($string)
47 Decimal (base 10) mode. This is mainly useful when referencing 8-bit
48 code pages like ISO-8859-1 or 7-bit ones like ASCII variants.
49
50 use utf8;
51 say dump_dec('Ĝis! ☺'); # 284 105 115 33 32 9786
52
53 no utf8;
54 say dump_dec('Ĝis! ☺'); # 196 156 105 115 33 32 226 152 186
55
56 dump_oct($string)
57 Octal (base 8) mode. This is mainly useful when referencing 7-bit code
58 pages like ASCII variants.
59
60 use utf8;
61 say dump_oct('Ĝis! ☺'); # 434 151 163 41 40 23072
62
63 no utf8;
64 say dump_oct('Ĝis! ☺'); # 304 234 151 163 41 40 342 230 272
65
66 dump_bin($string)
67 Binary (base 2) mode.
68
69 use utf8;
70 say dump_bin('Ĝis! ☺');
71 # 100011100 1101001 1110011 100001 100000 10011000111010
72
73 no utf8;
74 say dump_bin('Ĝis! ☺');
75 # 11000100 10011100 1101001 1110011 100001 100000 11100010 10011000 10111010
76
77 dump_names($string)
78 Unicode character name mode. Unlike the various numeral modes above,
79 this mode uses “, ” <comma, space> for the delimiter and it only makes
80 sense for Unicode strings, not byte strings.
81
82 use utf8;
83 say dump_names('Ĝis! ☺');
84 # LATIN CAPITAL LETTER G WITH CIRCUMFLEX, LATIN SMALL LETTER I,
85 # LATIN SMALL LETTER S, EXCLAMATION MARK, SPACE, WHITE SMILING FACE
86
87 The output in the example above has been manually split into multiple
88 lines for the layout of this document.
89
90 dump_codes($string)
91 Unicode code point mode. This is similar to "dump_hex" except it follows
92 the standard Unicode code point notation. The hex value is 4 to 6
93 digits, padded with “0” <digit zero> when less than 4, and prefixed with
94 “U+” <latin capital letter u, plus sign>. As with "dump_names", this
95 function only makes sense for Unicode strings, not byte strings.
96
97 use utf8;
98 say dump_codes('Ĝis! ☺'); # U+011C U+0069 U+0073 U+0021 U+0020 U+263A
99
100SEE ALSO
101 * dumpstr - Dump strings of characters on the command line
102
103 * String::Dump::Debugging - String debugging tips with String::Dump
104
105 * Template::Plugin::StringDump - String::Dump plugin for TT
106
107 * Data::HexDump - Simple hex dumping using the default output of the
108 Unix "hexdump" utility
109
110 * Data::Hexdumper - Advanced formatting of binary data, similar to
111 "hexdump"
112
113AUTHOR
114 Nick Patch <patch@cpan.org>
115
116COPYRIGHT AND LICENSE
117 © 2011–2013 Nick Patch
118
119 This library is free software; you can redistribute it and/or modify it
120 under the same terms as Perl itself.
121
122