| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Text::CSV::Encoded::Coder::EncodeGuess; | 
| 2 |  |  |  |  |  |  | $Text::CSV::Encoded::Coder::EncodeGuess::VERSION = '0.25'; | 
| 3 | 1 |  |  | 1 |  | 15 | use 5.008; | 
|  | 1 |  |  |  |  | 2 |  | 
| 4 | 1 |  |  | 1 |  | 3 | use strict; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 14 |  | 
| 5 | 1 |  |  | 1 |  | 2 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 23 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | # VERSION | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 2 | use base qw( Text::CSV::Encoded::Coder::Encode ); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 364 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 1 |  |  | 1 |  | 4 | use Carp (); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 9 |  | 
| 12 | 1 |  |  | 1 |  | 3 | use Encode (); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 11 |  | 
| 13 | 1 |  |  | 1 |  | 372 | use Encode::Guess; | 
|  | 1 |  |  |  |  | 2918 |  | 
|  | 1 |  |  |  |  | 3 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | sub decode { | 
| 17 | 2 |  |  | 2 | 1 | 3 | my ( $self, $encoding, $str ) = @_; | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 2 | 50 |  |  |  | 3 | return undef unless defined $str; | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 2 | 50 |  |  |  | 4 | if ( ref $encoding ) { | 
| 22 | 2 |  |  |  |  | 5 | my $enc = Encode::Guess::guess_encoding( $str, @$encoding ); | 
| 23 | 2 | 50 |  |  |  | 128 | $enc = $self->find_encoding( $encoding->[0] ) unless ref $enc; | 
| 24 | 2 |  |  |  |  | 5 | return $enc->decode( $str, $self->decode_check_value ); | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 0 |  |  |  |  | 0 | $self->find_encoding( $encoding )->decode( $str, $self->decode_check_value ); | 
| 28 |  |  |  |  |  |  | } | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | sub decode_fields_ref { | 
| 32 | 1 |  |  | 1 | 1 | 2 | my ( $self, $encoding, $arrayref ) = @_; | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 1 | 50 |  |  |  | 3 | if ( ref $encoding ) { | 
| 35 | 1 |  |  |  |  | 1 | for ( @$arrayref ) { | 
| 36 | 2 |  |  |  |  | 4 | my $enc = Encode::Guess::guess_encoding( $_, @$encoding ); | 
| 37 | 2 | 50 |  |  |  | 146 | $enc = $self->find_encoding( $encoding->[0] ) unless ref $enc; | 
| 38 | 2 |  |  |  |  | 6 | $_ = $enc->decode( $_, $self->decode_check_value ); | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  | else { | 
| 42 | 0 |  | 0 |  |  |  | my $enc = $self->find_encoding( $encoding ) || return; | 
| 43 | 0 |  |  |  |  |  | for ( @$arrayref ) { | 
| 44 | 0 |  |  |  |  |  | $_ = $enc->decode( $_, $self->decode_check_value ); | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | 1; | 
| 52 |  |  |  |  |  |  | __END__ |