line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::CSV::Encoded::Coder::Encode; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
221
|
use 5.008; |
|
8
|
|
|
|
|
25
|
|
4
|
8
|
|
|
8
|
|
36
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
158
|
|
5
|
8
|
|
|
8
|
|
38
|
use warnings; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
286
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
38
|
use base qw( Text::CSV::Encoded::Coder::Base ); |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
4768
|
|
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
44
|
use Carp (); |
|
8
|
|
|
|
|
98
|
|
|
8
|
|
|
|
|
115
|
|
10
|
8
|
|
|
8
|
|
4124
|
use Encode (); |
|
8
|
|
|
|
|
55918
|
|
|
8
|
|
|
|
|
3600
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %EncoderCache; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub upgrade { |
18
|
5
|
50
|
|
5
|
1
|
32
|
utf8::upgrade( $_[1] ) if ( $_[1] ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub encode { |
23
|
29
|
|
|
29
|
1
|
150
|
my ( $self, $encoding, $str ) = @_; |
24
|
29
|
50
|
|
|
|
71
|
return undef unless defined $str; |
25
|
29
|
|
|
|
|
76
|
$self->find_encoding( $encoding )->encode( $str, $self->encode_check_value ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub decode { |
30
|
45
|
|
|
45
|
1
|
102
|
my ( $self, $encoding, $str ) = @_; |
31
|
45
|
100
|
|
|
|
120
|
return undef unless defined $str; |
32
|
|
|
|
|
|
|
|
33
|
44
|
100
|
66
|
|
|
319
|
if ( $self->{automatic_UTF8} and $encoding =~ /utf-?8/i ) { |
34
|
27
|
|
|
|
|
123
|
return $str; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
17
|
|
|
|
|
39
|
$self->find_encoding( $encoding )->decode( $str, $self->decode_check_value ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub decode_fields_ref { |
42
|
21
|
|
|
21
|
1
|
34
|
my ( $self, $encoding, $arrayref ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
21
|
100
|
66
|
|
|
126
|
if ( $self->{automatic_UTF8} and $encoding =~ /utf-?8/i ) { |
45
|
5
|
|
|
|
|
12
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
16
|
|
50
|
|
|
31
|
my $enc = $self->find_encoding( $encoding ) || return; |
49
|
16
|
|
|
|
|
35
|
for ( @$arrayref ) { |
50
|
16
|
50
|
|
|
|
69
|
$_ = $enc->decode( $_, $self->decode_check_value ) if defined $_; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub encode_fields_ref { |
56
|
12
|
|
|
12
|
1
|
17
|
my ( $self, $encoding, $arrayref ) = @_; |
57
|
12
|
|
50
|
|
|
32
|
my $enc = $self->find_encoding( $encoding ) || return; |
58
|
12
|
|
|
|
|
10103
|
for ( @$arrayref ) { |
59
|
12
|
50
|
|
|
|
72
|
$_ = $enc->encode( $_, $self->encode_check_value ) if defined $_; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub find_encoding { |
65
|
74
|
|
|
74
|
0
|
89
|
shift; |
66
|
74
|
|
50
|
|
|
451
|
$EncoderCache { ($_[0] || 'utf8') } |
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
|
|
|
|
||= Encode::find_encoding( $_[0] || 'utf8' ) || Carp::croak ( "Not found such an encoding name '$_[0]'" ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
__END__ |