Deprecated.
NAME
Data::Visitor::Encode - Encode/Decode Values In A Structure (DEPRECATED)
SYNOPSIS
# THIS MODULE IS NOW DEPRECATED. Use Data::Recursive::Encode instead
use Data::Visitor::Encode;
my $dev = Data::Visitor::Encode->new();
my %hash = (...); # assume data is in Perl native Unicode
$dev->encode('euc-jp', \%hash); # now strings are in euc-jp
$dev->decode('euc-jp', \%hash); # now strings are back in unicode
$dev->utf8_on(\%hash);
$dev->utf8_off(\%hash);
DEPRECATION ALERT
This module has been DEPRECATED in favor of 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)
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)
METHODS
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
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
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.
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.
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.
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.
h2z
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.
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.
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.
do_decode
do_encode
do_utf8_off
do_utf8_on
do_h2z
do_z2h
do_encode_utf8
do_decode_utf8
visit_glob
visit_hash
visit_object
visit_scalar
visit_value
These methods are private. Only use if it you are subclassing this class.
AUTHOR
Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>
SEE ALSO
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html