root/lang/perl/autobox-Encode/trunk/lib/autobox/Encode.pm @ 4865

Revision 4865, 1.1 kB (checked in by miyagawa, 7 years ago)

added charname

Line 
1package autobox::Encode;
2use strict;
3use charnames ();
4use warnings;
5use autobox;
6use Encode;
7
8our $VERSION = '0.01';
9
10package SCALAR;
11sub encode { Encode::encode($_[1], $_[0], $_[2]) }
12sub decode { Encode::decode($_[1], $_[0], $_[2]) }
13sub is_utf8 { Encode::is_utf8($_[0]) }
14sub from_to { Encode::from_to($_[0], $_[1], $_[2]); $_[0] }
15
16sub charname {
17    my $string = shift;
18    join '', map charnames::viacode(ord), split //, $string;
19}
20
211;
22
23__END__
24
25=head1 NAME
26
27autobox::Encode - Encode with autobox
28
29=head1 SYNOPSIS
30
31  use autobox;
32  use autobox::Encode;
33
34  "Foo"->decode('utf-8')->encode('utf-8')
35
36  my $latin1_bytes = ...;
37  my $utf8_bytes   = $latin1_bytes->from_to('latin-1' => 'utf-8');
38
39  "\x{1234}"->charname; # "ETHIOPIC SYLLABLE SEE"
40
41=head1 DESCRIPTION
42
43use Encode with autobox!
44
45=head1 AUTHOR
46
47Tokuhiro Matsuno <tokuhirom gmail com>
48
49=head1 THANKS
50
51#coderepos
52
53=head1 COPYRIGHT
54
55This program is free software; you can redistribute
56it and/or modify it under the same terms as Perl itself.
57
58The full text of the license can be found in the
59LICENSE file included with this module.
60
61=cut
Note: See TracBrowser for help on using the browser.