Integrate mainline (Win2k/MinGW all ok except threads/t/end.t)
[p5sagit/p5-mst-13.2.git] / ext / Encode / lib / Encode / Unicode.pm
1 package Encoding::Unicode;
2 use strict;
3 our $VERSION = do { my @r = (q$Revision: 0.92 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
4
5 use base 'Encode::Encoding';
6
7 __PACKAGE__->Define('Unicode') unless ord('A') == 65;
8
9 sub 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
21 sub 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
33 1;
34 __END__