Duh. If the input is a stream of UTF-8 bytes, all that's
[p5sagit/p5-mst-13.2.git] / ext / Encode / lib / Encode / utf8.pm
1 package Encode::utf8;
2 use strict;
3 our $VERSION = do { my @r = (q$Revision: 1.20 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
4
5 use base 'Encode::Encoding';
6 # package to allow long-hand
7 #   $octets = encode( utf8 => $string );
8 #
9
10 __PACKAGE__->Define(qw(utf8));
11
12 sub decode
13 {
14     my ($obj,$octets,$chk) = @_;
15     my $str = Encode::decode_utf8($octets);
16     if (defined $str)
17     {
18         $_[1] = '' if $chk;
19         return $str;
20     }
21     return undef;
22 }
23
24 sub encode
25 {
26     my ($obj,$string,$chk) = @_;
27     my $octets = Encode::encode_utf8($string);
28     $_[1] = '' if $chk;
29     return $octets;
30 }
31 1;
32 __END__
33
34 =head1 NAME
35
36 Encode::utf8 -- for internal use only
37
38 =cut