line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Provider::Encode::Guess; |
2
|
1
|
|
|
1
|
|
31879
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use base qw(Template::Provider); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2056
|
|
6
|
1
|
|
|
1
|
|
31025
|
use Encode; |
|
1
|
|
|
|
|
12304
|
|
|
1
|
|
|
|
|
104
|
|
7
|
1
|
|
|
1
|
|
914
|
use Encode::Guess; |
|
1
|
|
|
|
|
5136
|
|
|
1
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
10
|
|
|
|
|
|
|
our $OUTPUT_ENCODING; |
11
|
|
|
|
|
|
|
our @SUSPECTS; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
1
|
|
|
1
|
1
|
20
|
my $class = shift; |
15
|
1
|
|
|
|
|
2
|
my $options = shift; |
16
|
|
|
|
|
|
|
|
17
|
1
|
50
|
|
|
|
6
|
$OUTPUT_ENCODING = exists $options->{oe} ? $options->{oe} : undef; |
18
|
1
|
|
|
|
|
4
|
delete $options->{oe}; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
16
|
return $class->SUPER::new($options); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _load { |
24
|
1
|
|
|
1
|
|
29298
|
my $self = shift; |
25
|
1
|
|
|
|
|
10
|
my ($data, $error) = $self->SUPER::_load(@_); |
26
|
|
|
|
|
|
|
|
27
|
1
|
50
|
33
|
|
|
259
|
unless ($OUTPUT_ENCODING and @SUSPECTS) { |
28
|
0
|
|
|
|
|
0
|
return ($data, $error); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
9
|
my $enc = guess_encoding($data->{text}, @SUSPECTS); |
32
|
|
|
|
|
|
|
|
33
|
1
|
50
|
|
|
|
12034
|
unless ( ref($enc) ) { |
34
|
0
|
|
|
|
|
0
|
return ($data, $error); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
12
|
Encode::from_to($data->{text}, $enc->name, $OUTPUT_ENCODING ); |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
214
|
return ($data, $error); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub import { |
43
|
1
|
|
|
1
|
|
12
|
my $pack = shift; |
44
|
1
|
|
|
|
|
25
|
@SUSPECTS = @_; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
__END__ |