Skip to content

Commit

Permalink
release 0.03
Browse files Browse the repository at this point in the history
  • Loading branch information
patch committed Dec 13, 2011
1 parent 471ceea commit ed1049e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 33 deletions.
7 changes: 7 additions & 0 deletions Changes
@@ -1,4 +1,11 @@
---
version: 0.03
date: 2011-12-12
changes:
- Renamed dump_string() to dumpstr()
- Added dump_string() as an alias of dumpstr()
- [NOTE] Automatic dump_string() exporting will be removed in the next release
---
version: 0.02
date: 2011-12-12
changes:
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -9,6 +9,7 @@ META.yml
README
t/00-load.t
t/dump_string.t
t/dumpstr.t
xt/author/kwalitee.t
xt/author/pod-coverage.t
xt/author/pod.t
Expand Down
60 changes: 31 additions & 29 deletions README
Expand Up @@ -3,28 +3,30 @@ NAME
debugging

VERSION
This document describes String::Dump version 0.02.
This document describes String::Dump version 0.03.

SYNOPSIS
use String::Dump;

say 'hex: ', dump_string($string); # hex mode by default
say 'oct: ', dump_string(oct => $string); # octal mode
say 'hex: ', dumpstr($string); # hex mode by default
say 'oct: ', dumpstr(oct => $string); # octal mode

DESCRIPTION
This module provides the function "dump_string" and exports it by
default. When debugging or reviewing non-ASCII data, "dump_string" is
your friend. It's a simple utility to view the characters or bytes of
your string in several different formats, such as hex, octal, decimal,
Unicode names, and more.
This module provides the "dumpstr" function and exports it by default.
Those who prefer their function names unabridged may manually export
"dump_string" instead. When debugging or reviewing strings containing
non-ASCII or non-printing characters, "dumpstr" is your friend. It's a
simple utility to view the characters or bytes of your string in several
different formats, such as hex, octal, decimal, Unicode names, and more.

An OO interface is forthcoming with additional options and the ability
to reuse them among multiple calls. Some benefits will be the ability to
set the delimiter between characters and to force a string to be treated
as a string of characters or a series of bytes. Don't worry, the
"dump_string" function will remain simple.
to reuse them among multiple calls. Some benefits will include the
ability to set the delimiter between characters, set padding for the
characters, and force a string to be treated as a string of characters
or a series of bytes. Don't worry, the "dumpstr" function will remain
simple.

dump_string($mode, $string)
dumpstr($mode, $string)
The mode is optional and defaults to "hex". Other valid modes are "dec",
"oct", "bin", and "names", and are described below. The string may
either be a series of Unicode characters or binary bytes.
Expand All @@ -36,60 +38,60 @@ DESCRIPTION

use utf8;
# string of 6 characters
say dump_string('Ĝis! ☺'); # 11C 69 73 21 20 263A
say dump_string(hex => 'Ĝis! ☺'); # same thing
say dumpstr('Ĝis! ☺'); # 11C 69 73 21 20 263A
say dumpstr(hex => 'Ĝis! ☺'); # same thing

no utf8;
# series of 9 bytes
say dump_string('Ĝis! ☺'); # C4 9C 69 73 21 20 E2 98 BA
say dumpstr('Ĝis! ☺'); # C4 9C 69 73 21 20 E2 98 BA

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

say lc dump_string('Ĝis! ☺'); # 11c 69 73 21 20 263a
say lc dumpstr('Ĝis! ☺'); # 11c 69 73 21 20 263a

dec
Decimal (base 10) mode.

use utf8;
say dump_string(dec => 'Ĝis! ☺'); # 284 105 115 33 32 9786
say dumpstr(dec => 'Ĝis! ☺'); # 284 105 115 33 32 9786

no utf8;
say dump_string(dec => 'Ĝis! ☺'); # 196 156 105 115 33 32 226 152 186
say dumpstr(dec => 'Ĝis! ☺'); # 196 156 105 115 33 32 226 152 186

oct
Octal (base 8) mode.

use utf8;
say dump_string(oct => 'Ĝis! ☺'); # 434 151 163 41 40 23072
say dumpstr(oct => 'Ĝis! ☺'); # 434 151 163 41 40 23072

no utf8;
say dump_string(oct => 'Ĝis! ☺'); # 304 234 151 163 41 40 342 230 272
say dumpstr(oct => 'Ĝis! ☺'); # 304 234 151 163 41 40 342 230 272

bin
Binary (base 2) mode.

use utf8;
say dump_string(bin => 'Ĝis! ☺');
say dumpstr(bin => 'Ĝis! ☺');
# 100011100 1101001 1110011 100001 100000 10011000111010

no utf8;
say dump_string(bin => 'Ĝis! ☺');
say dumpstr(bin => 'Ĝis! ☺');
# 11000100 10011100 1101001 1110011 100001 100000 11100010 10011000 10111010

names
Named Unicode character mode. Unlike the various numeral modes above,
this mode uses ', ' for the delimiter.

use utf8;
say dump_string(names => 'Ĝis! ☺');
say dumpstr(names => 'Ĝis! ☺');
# LATIN CAPITAL LETTER G WITH CIRCUMFLEX, LATIN SMALL LETTER I,
# LATIN SMALL LETTER S, EXCLAMATION MARK, SPACE, WHITE SMILING FACE

This mode makes no sense for a series of bytes, but it still works if
that's what you really want!

no utf8;
say dump_string(names => 'Ĝis! ☺');
say dumpstr(names => 'Ĝis! ☺');
# LATIN CAPITAL LETTER A WITH DIAERESIS, STRING TERMINATOR,
# LATIN SMALL LETTER I, LATIN SMALL LETTER S, EXCLAMATION MARK,
# SPACE, LATIN SMALL LETTER A WITH CIRCUMFLEX, START OF STRING,
Expand All @@ -109,10 +111,10 @@ DESCRIPTION

{
no utf8;
say dump_string('Ĝis! ☺'); # C4 9C 69 73 21 20 E2 98 BA
say dumpstr('Ĝis! ☺'); # C4 9C 69 73 21 20 E2 98 BA
}

say dump_string('Ĝis! ☺'); # 11C 69 73 21 20 263A
say dumpstr('Ĝis! ☺'); # 11C 69 73 21 20 263A

Command-line input and filehandles
The simplest way to ensure that you're working with strings of
Expand All @@ -128,13 +130,13 @@ DESCRIPTION

use Encode;

say dump_string( decode_utf8($string) );
say dumpstr( decode_utf8($string) );

To convert a variable in-place, pass it to utf8::decode instead.

utf8::decode($string);

say dump_string($string);
say dumpstr($string);

CONTRIBUTIONS
This is an early release of String::Dump. Feedback is appreciated! To
Expand Down
6 changes: 3 additions & 3 deletions lib/String/Dump.pm
Expand Up @@ -6,8 +6,8 @@ use warnings;
use charnames qw( :full );
use parent 'Exporter';

our $VERSION = '0.02';
our @EXPORT = qw( dumpstr dump_string );
our $VERSION = '0.03';
our @EXPORT = qw( dumpstr dump_string );
# TODO: remove dump_string from @EXPORT
#our @EXPORT_OK = qw( dump_string );

Expand Down Expand Up @@ -58,7 +58,7 @@ String::Dump - Dump strings of characters or bytes for printing and debugging
=head1 VERSION
This document describes String::Dump version 0.02.
This document describes String::Dump version 0.03.
=head1 SYNOPSIS
Expand Down
2 changes: 1 addition & 1 deletion xt/author/pod-coverage.t
Expand Up @@ -5,4 +5,4 @@ use Test::More;
eval 'use Test::Pod::Coverage 1.00';
plan skip_all => 'Test::Pod::Coverage 1.00 not installed; skipping' if $@;

all_pod_coverage_ok();
all_pod_coverage_ok({ trustme => [qw< dump_string >] });

0 comments on commit ed1049e

Please sign in to comment.