| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Encode::Encoding; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | # Base class for classes which implement encodings | 
| 4 | 40 |  |  | 40 |  | 21875 | use strict; | 
|  | 40 |  |  |  |  | 128 |  | 
|  | 40 |  |  |  |  | 1401 |  | 
| 5 | 40 |  |  | 40 |  | 1353 | use warnings; | 
|  | 40 |  |  |  |  | 113 |  | 
|  | 40 |  |  |  |  | 5507 |  | 
| 6 |  |  |  |  |  |  | our $VERSION = do { my @r = ( q$Revision: 2.8 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | our @CARP_NOT = qw(Encode Encode::Encoder); | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 40 |  |  | 40 |  | 371 | use Carp (); | 
|  | 40 |  |  |  |  | 113 |  | 
|  | 40 |  |  |  |  | 876 |  | 
| 11 | 40 |  |  | 40 |  | 277 | use Encode (); | 
|  | 40 |  |  |  |  | 116 |  | 
|  | 40 |  |  |  |  | 977 |  | 
| 12 | 40 |  |  | 40 |  | 279 | use Encode::MIME::Name; | 
|  | 40 |  |  |  |  | 126 |  | 
|  | 40 |  |  |  |  | 1678 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 40 |  |  | 40 |  | 1360 | use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG}; | 
|  | 40 |  |  |  |  | 833 |  | 
|  | 40 |  |  |  |  | 47763 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | sub Define { | 
| 17 | 28 |  |  | 28 | 0 | 106 | my $obj       = shift; | 
| 18 | 28 |  |  |  |  | 141 | my $canonical = shift; | 
| 19 | 28 | 50 |  |  |  | 214 | $obj = bless { Name => $canonical }, $obj unless ref $obj; | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | # warn "$canonical => $obj\n"; | 
| 22 | 28 |  |  |  |  | 188 | Encode::define_encoding( $obj, $canonical, @_ ); | 
| 23 |  |  |  |  |  |  | } | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 590 |  |  | 590 | 1 | 172017 | sub name { return shift->{'Name'} } | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | sub mime_name { | 
| 28 | 25 |  |  | 25 | 1 | 245 | return Encode::MIME::Name::get_mime_name(shift->name); | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | sub renew { | 
| 32 | 24 |  |  | 24 | 1 | 80 | my $self = shift; | 
| 33 | 24 |  |  |  |  | 219 | my $clone = bless {%$self} => ref($self); | 
| 34 | 24 |  |  |  |  | 89 | $clone->{renewed}++;    # so the caller can see it | 
| 35 | 24 |  |  |  |  | 56 | DEBUG and warn $clone->{renewed}; | 
| 36 | 24 |  |  |  |  | 166 | return $clone; | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 30304 |  | 100 | 30304 | 1 | 309103 | sub renewed { return $_[0]->{renewed} || 0 } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | *new_sequence = \&renew; | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 14 |  |  | 14 | 1 | 123 | sub needs_lines { 0 } | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | sub perlio_ok { | 
| 46 | 8 | 50 |  | 8 | 1 | 35 | return eval { require PerlIO::encoding } ? 1 : 0; | 
|  | 8 |  |  |  |  | 122 |  | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | # (Temporary|legacy) methods | 
| 50 |  |  |  |  |  |  |  | 
| 51 | 0 |  |  | 0 | 0 | 0 | sub toUnicode   { shift->decode(@_) } | 
| 52 | 0 |  |  | 0 | 0 | 0 | sub fromUnicode { shift->encode(@_) } | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | # | 
| 55 |  |  |  |  |  |  | # Needs to be overloaded or just croak | 
| 56 |  |  |  |  |  |  | # | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | sub encode { | 
| 59 | 1 |  |  | 1 | 1 | 5 | my $obj = shift; | 
| 60 | 1 | 50 |  |  |  | 8 | my $class = ref($obj) ? ref($obj) : $obj; | 
| 61 | 1 |  |  |  |  | 538 | Carp::croak( $class . "->encode() not defined!" ); | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | sub decode { | 
| 65 | 0 |  |  | 0 | 1 |  | my $obj = shift; | 
| 66 | 0 | 0 |  |  |  |  | my $class = ref($obj) ? ref($obj) : $obj; | 
| 67 | 0 |  |  |  |  |  | Carp::croak( $class . "->encode() not defined!" ); | 
| 68 |  |  |  |  |  |  | } | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  | 0 |  |  | sub DESTROY { } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | 1; | 
| 73 |  |  |  |  |  |  | __END__ |