| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::Liberal::Remedy::NotUTF8; |
|
2
|
2
|
|
|
2
|
|
1594
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
78
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use Encode; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
201
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use Encode::Guess; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub apply { |
|
8
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
9
|
0
|
|
|
|
|
|
my($driver, $error, $xml_ref) = @_; |
|
10
|
|
|
|
|
|
|
|
|
11
|
0
|
0
|
|
|
|
|
return 0 if $error->message !~ |
|
12
|
|
|
|
|
|
|
/^parser error : Input is not proper UTF-8, indicate encoding !/; |
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
my @suspects = @{ $driver->guess_encodings || [ qw(euc-jp shift_jis utf-8) ] }; |
|
|
0
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $enc = guess_encoding($$xml_ref, @suspects); |
|
16
|
0
|
0
|
|
|
|
|
if (ref($enc)) { |
|
17
|
0
|
|
|
|
|
|
Encode::from_to($$xml_ref, $enc->name, "UTF-8"); |
|
18
|
0
|
|
|
|
|
|
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; |