Data-Visitor-Encode
view release on metacpan or search on metacpan
lib/Data/Visitor/Encode.pm view on Meta::CPAN
=head1 DEPRECATION ALERT
This module has been DEPRECATED in favor of L<Data::Recursive::Encode>. Bug reports will not be acted upon, and the module will cease to exist from CPAN by the end of year 2011.
You've been warned (since 2009)
=head1 DESCRIPTION
Data::Visitor::Encode visits each node of a structure, and returns a new
structure with each node's encoding (or similar action). If you ever wished
to do a bulk encode/decode of the contents of a structure, then this
module may help you.
Starting from 0.09000, you can directly use the methods without instantiating
the object:
Data::Visitor::Encode->encode('euc-jp', $obj);
# instead of Data::Visitor::Encode->new->encod('euc-jp', $obj)
=head1 METHODS
=head2 utf8_on
$dev->utf8_on(\%hash);
$dev->utf8_on(\@list);
$dev->utf8_on(\$scalar);
$dev->utf8_on($scalar);
$dev->utf8_on($object);
Returns a structure containing nodes with utf8 flag on
=head2 utf8_off
$dev->utf8_off(\%hash);
$dev->utf8_off(\@list);
$dev->utf8_off(\$scalar);
$dev->utf8_off($scalar);
$dev->utf8_off($object);
Returns a structure containing nodes with utf8 flag off
=head2 encode
$dev->encode($encoding, \%hash [, CHECK]);
$dev->encode($encoding, \@list [, CHECK]);
$dev->encode($encoding, \$scalar [, CHECK]);
$dev->encode($encoding, $scalar [, CHECK]);
$dev->encode($encoding, $object [, CHECK]);
Returns a structure containing nodes which are encoded in the specified
encoding.
=head2 decode
$dev->decode($encoding, \%hash);
$dev->decode($encoding, \@list);
$dev->decode($encoding, \$scalar);
$dev->decode($encoding, $scalar);
$dev->decode($encoding, $object);
Returns a structure containing nodes which are decoded from the specified
encoding.
=head2 decode_utf8
$dev->decode_utf8(\%hash);
$dev->decode_utf8(\@list);
$dev->decode_utf8(\$scalar);
$dev->decode_utf8($scalar);
$dev->decode_utf8($object);
Returns a structure containing nodes which have been processed through
decode_utf8.
=head2 encode_utf8
$dev->encode_utf8(\%hash);
$dev->encode_utf8(\@list);
$dev->encode_utf8(\$scalar);
$dev->encode_utf8($scalar);
$dev->encode_utf8($object);
Returns a structure containing nodes which have been processed through
encode_utf8.
=head2 h2z
=head2 z2h
$dev->h2z($encoding, \%hash);
$dev->h2z($encoding, \@list);
$dev->h2z($encoding, \$scalar);
$dev->h2z($encoding, $scalar);
$dev->h2z($encoding, $object);
h2z and z2h are Japanese-only methods (hey, I'm a little biased like that).
They perform the task of mapping half-width katakana to full-width katakana
and vice-versa.
These methods use Encode::JP::H2Z, which requires us to go from the
original encoding to euc-jp and then back. There are other modules that are
built to handle exactly this problem, which may come out to be faster than
using Encode.pm's somewhat hidden Encode::JP::H2Z, but I really don't care
for adding another dependency to this module other than Encode.pm, so
here it is.
If you're significantly worried about performance, I'll gladly accept patches
as long as there are no prerequisite modules or the prerequisite is optional.
=head2 decode_utf8
$dev->decode_utf8(\%hash);
$dev->decode_utf8(\@list);
$dev->decode_utf8(\$scalar);
$dev->decode_utf8($scalar);
$dev->decode_utf8($object);
Returns a structure containing nodes which have been processed through
decode_utf8.
=head2 encode_utf8
( run in 3.018 seconds using v1.01-cache-2.11-cpan-ceb78f64989 )