GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
String::Dump(3) User Contributed Perl Documentation String::Dump(3)

String::Dump - Dump strings of characters (or bytes) for printing and debugging

This document describes String::Dump version 0.09.

    use String::Dump qw( dump_hex dump_bin );

    say 'hex: ', dump_hex($string);
    say 'bin: ', dump_bin($string);

When debugging or examining strings containing non-ASCII or non-printing characters, String::Dump is your friend. It provides simple functions to return a dump of the code points for Unicode strings or the bytes for byte strings in several different formats, such as hex, binary, Unicode names, and more.

For using this module from the command line, see the bundled dumpstr script. For tips on debugging Unicode or byte strings with this module, see the document String::Dump::Debugging.

These functions all accept a single argument: the string to dump, which may either be a Unicode string or a byte string. All functions are exported by default unless specific ones are requested. The ":all" tag may be used to explicitly export all functions.

Hexadecimal (base 16) mode.

    use utf8;
    # string of 6 characters
    say dump_hex('Xis! X');  # 11C 69 73 21 20 263A

    no utf8;
    # series of 9 bytes
    say dump_hex('Xis! X');  # C4 9C 69 73 21 20 E2 98 BA

For a lowercase hex dump, simply pass the response to "lc".

    say lc dump_hex('Xis! X');  # 11c 69 73 21 20 263a

Decimal (base 10) mode. This is mainly useful when referencing 8-bit code pages like ISO-8859-1 or 7-bit ones like ASCII variants.

    use utf8;
    say dump_dec('Xis! X');  # 284 105 115 33 32 9786

    no utf8;
    say dump_dec('Xis! X');  # 196 156 105 115 33 32 226 152 186

Octal (base 8) mode. This is mainly useful when referencing 7-bit code pages like ASCII variants.

    use utf8;
    say dump_oct('Xis! X');  # 434 151 163 41 40 23072

    no utf8;
    say dump_oct('Xis! X');  # 304 234 151 163 41 40 342 230 272

Binary (base 2) mode.

    use utf8;
    say dump_bin('Xis! X');
    # 100011100 1101001 1110011 100001 100000 10011000111010

    no utf8;
    say dump_bin('Xis! X');
    # 11000100 10011100 1101001 1110011 100001 100000 11100010 10011000 10111010

Unicode character name mode. Unlike the various numeral modes above, this mode uses X, X <comma, space> for the delimiter and it only makes sense for Unicode strings, not byte strings.

    use utf8;
    say dump_names('Xis! X');
    # LATIN CAPITAL LETTER G WITH CIRCUMFLEX, LATIN SMALL LETTER I,
    # LATIN SMALL LETTER S, EXCLAMATION MARK, SPACE, WHITE SMILING FACE

The output in the example above has been manually split into multiple lines for the layout of this document.

Unicode code point mode. This is similar to "dump_hex" except it follows the standard Unicode code point notation. The hex value is 4 to 6 digits, padded with X0X <digit zero> when less than 4, and prefixed with XU+X <latin capital letter u, plus sign>. As with "dump_names", this function only makes sense for Unicode strings, not byte strings.

    use utf8;
    say dump_codes('Xis! X');  # U+011C U+0069 U+0073 U+0021 U+0020 U+263A

  • dumpstr - Dump strings of characters on the command line
  • String::Dump::Debugging - String debugging tips with String::Dump
  • Template::Plugin::StringDump - String::Dump plugin for TT
  • Data::HexDump - Simple hex dumping using the default output of the Unix "hexdump" utility
  • Data::Hexdumper - Advanced formatting of binary data, similar to "hexdump"

Nick Patch <patch@cpan.org>

X 2011X2013 Nick Patch

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2022-04-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.