| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::Liberal::Remedy::NotUTF8; |
|
2
|
5
|
|
|
5
|
|
2307
|
use strict; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
116
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
16
|
use Encode; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
297
|
|
|
5
|
5
|
|
|
5
|
|
22
|
use Encode::Guess; |
|
|
5
|
|
|
|
|
5
|
|
|
|
5
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub apply { |
|
8
|
91
|
|
|
91
|
0
|
133
|
my $class = shift; |
|
9
|
91
|
|
|
|
|
155
|
my($driver, $error, $xml_ref) = @_; |
|
10
|
|
|
|
|
|
|
|
|
11
|
91
|
100
|
|
|
|
168
|
return 0 if $error->message !~ |
|
12
|
|
|
|
|
|
|
/^parser error : Input is not proper UTF-8, indicate encoding !/; |
|
13
|
|
|
|
|
|
|
|
|
14
|
5
|
50
|
|
|
|
47
|
my @suspects = @{ $driver->guess_encodings || [ qw(euc-jp shift_jis utf-8) ] }; |
|
|
5
|
|
|
|
|
31
|
|
|
15
|
5
|
|
|
|
|
77
|
my $enc = guess_encoding($$xml_ref, @suspects); |
|
16
|
5
|
50
|
|
|
|
2406
|
if (ref($enc)) { |
|
17
|
5
|
|
|
|
|
28
|
Encode::from_to($$xml_ref, $enc->name, "UTF-8"); |
|
18
|
5
|
|
|
|
|
244
|
return 1; |
|
19
|
|
|
|
|
|
|
} else { |
|
20
|
|
|
|
|
|
|
# fallback to UTF-8 and do roundtrip conversion |
|
21
|
0
|
|
|
|
|
|
my $old = $$xml_ref; |
|
22
|
0
|
|
|
|
|
|
my $xml = Encode::encode("utf-8", Encode::decode("utf-8", $$xml_ref)); |
|
23
|
0
|
|
|
|
|
|
$$xml_ref = $xml; |
|
24
|
0
|
|
|
|
|
|
return $$xml_ref ne $old; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |