line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::CSV::Encoded::Coder::Encode; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
209
|
use 5.008; |
|
8
|
|
|
|
|
29
|
|
4
|
8
|
|
|
8
|
|
43
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
176
|
|
5
|
8
|
|
|
8
|
|
41
|
use warnings; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
305
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
46
|
use base qw( Text::CSV::Encoded::Coder::Base ); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
4895
|
|
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
44
|
use Carp (); |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
120
|
|
10
|
8
|
|
|
8
|
|
4012
|
use Encode (); |
|
8
|
|
|
|
|
56416
|
|
|
8
|
|
|
|
|
3693
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %EncoderCache; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub upgrade { |
18
|
5
|
50
|
|
5
|
1
|
30
|
utf8::upgrade( $_[1] ) if ( $_[1] ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub encode { |
23
|
29
|
|
|
29
|
1
|
143
|
my ( $self, $encoding, $str ) = @_; |
24
|
29
|
50
|
|
|
|
67
|
return undef unless defined $str; |
25
|
29
|
|
|
|
|
65
|
$self->find_encoding( $encoding )->encode( $str, $self->encode_check_value ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub decode { |
30
|
45
|
|
|
45
|
1
|
88
|
my ( $self, $encoding, $str ) = @_; |
31
|
45
|
100
|
|
|
|
121
|
return undef unless defined $str; |
32
|
|
|
|
|
|
|
|
33
|
44
|
100
|
66
|
|
|
333
|
if ( $self->{automatic_UTF8} and $encoding =~ /utf-?8/i ) { |
34
|
27
|
|
|
|
|
149
|
return $str; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
17
|
|
|
|
|
36
|
$self->find_encoding( $encoding )->decode( $str, $self->decode_check_value ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub decode_fields_ref { |
42
|
21
|
|
|
21
|
1
|
32
|
my ( $self, $encoding, $arrayref ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
21
|
100
|
66
|
|
|
106
|
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
|
|
|
|
|
32
|
for ( @$arrayref ) { |
50
|
16
|
50
|
|
|
|
65
|
$_ = $enc->decode( $_, $self->decode_check_value ) if defined $_; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub encode_fields_ref { |
56
|
12
|
|
|
12
|
1
|
18
|
my ( $self, $encoding, $arrayref ) = @_; |
57
|
12
|
|
50
|
|
|
31
|
my $enc = $self->find_encoding( $encoding ) || return; |
58
|
12
|
|
|
|
|
9658
|
for ( @$arrayref ) { |
59
|
12
|
50
|
|
|
|
59
|
$_ = $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
|
|
|
429
|
$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__ |