Integrate mainline
[p5sagit/p5-mst-13.2.git] / ext / Encode / lib / Encode / Unicode.pm
CommitLineData
18586f54 1package Encoding::Unicode;
2use strict;
48e3bbdd 3our $VERSION = do { my @r = (q$Revision: 1.0 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
d6b7ef86 4
18586f54 5use base 'Encode::Encoding';
6
7__PACKAGE__->Define('Unicode') unless ord('A') == 65;
8
9sub decode
10{
11 my ($obj,$str,$chk) = @_;
12 my $res = '';
13 for (my $i = 0; $i < length($str); $i++)
14 {
15 $res .= chr(utf8::unicode_to_native(ord(substr($str,$i,1))));
16 }
17 $_[1] = '' if $chk;
18 return $res;
19}
20
21sub encode
22{
23 my ($obj,$str,$chk) = @_;
24 my $res = '';
25 for (my $i = 0; $i < length($str); $i++)
26 {
27 $res .= chr(utf8::native_to_unicode(ord(substr($str,$i,1))));
28 }
29 $_[1] = '' if $chk;
30 return $res;
31}
32
331;
34__END__
48e3bbdd 35
36=head1 NAME
37
38Encode::Unicode -- for internal use only
39
40=cut