line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DataStore::CAS::FS::InvalidUTF8; |
2
|
8
|
|
|
8
|
|
814
|
use strict; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
260
|
|
3
|
8
|
|
|
8
|
|
43
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
200
|
|
4
|
8
|
|
|
8
|
|
42
|
use Carp; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
793
|
|
5
|
8
|
|
|
8
|
|
46
|
use overload '""' => \&to_string, 'cmp' => \&str_compare, '.' => \&str_concat; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
163
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION= '0.011000'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Wrapper to represent non-utf8 data in a unicode context |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub decode_utf8 { |
13
|
66
|
|
|
66
|
1
|
4357
|
my $str= $_[-1]; |
14
|
66
|
50
|
33
|
|
|
342
|
!ref $str || ref($str)->isa(__PACKAGE__) |
15
|
|
|
|
|
|
|
or croak "Can't convert ".ref($str); |
16
|
66
|
100
|
66
|
|
|
1081
|
return ref($str) || utf8::is_utf8($str) || utf8::decode($str)? $str |
17
|
|
|
|
|
|
|
: bless(\$str, __PACKAGE__); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
1
|
0
|
sub is_non_unicode { 1 } |
21
|
|
|
|
|
|
|
|
22
|
13
|
|
|
13
|
1
|
4536
|
sub to_string { ${$_[0]} } |
|
13
|
|
|
|
|
474
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub str_compare { |
25
|
2
|
|
|
2
|
1
|
143
|
my ($self, $other, $swap)= @_; |
26
|
2
|
100
|
|
|
|
8
|
if (ref $other eq __PACKAGE__) { $other= $$other } else { utf8::encode($other) } |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
27
|
2
|
|
|
|
|
5
|
my $ret= $$self cmp $other; |
28
|
2
|
100
|
|
|
|
19
|
return $swap? -$ret : $ret; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub str_concat { |
32
|
2
|
|
|
2
|
1
|
6
|
my ($self, $other, $swap)= @_; |
33
|
2
|
100
|
|
|
|
6
|
if (ref $other eq __PACKAGE__) { $other= $$other } else { utf8::encode($other) } |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
34
|
2
|
100
|
|
|
|
12
|
return ref($self)->decode_utf8($swap? $other.$$self : $$self.$other); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub add_json_filter { |
39
|
5
|
|
|
5
|
1
|
27
|
my ($self, $json)= @_; |
40
|
5
|
|
|
|
|
107
|
$json->filter_json_single_key_object( |
41
|
|
|
|
|
|
|
'*InvalidUTF8*' => \&FROM_JSON |
42
|
|
|
|
|
|
|
); |
43
|
5
|
|
|
|
|
75
|
$json; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub TO_JSON { |
47
|
3
|
|
|
3
|
1
|
21
|
my $x= ${$_[0]}; |
|
3
|
|
|
|
|
36
|
|
48
|
3
|
|
|
|
|
11
|
utf8::upgrade($x); |
49
|
3
|
|
|
|
|
32
|
return { '*InvalidUTF8*' => $x }; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub FROM_JSON { |
53
|
3
|
|
|
3
|
1
|
19
|
my $x= $_[0]; |
54
|
3
|
50
|
|
|
|
17
|
utf8::downgrade($x) if utf8::is_utf8($x); |
55
|
3
|
|
|
|
|
28
|
return bless \$x, __PACKAGE__; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub TO_UTF8 { |
59
|
4
|
|
|
4
|
0
|
11
|
${$_[0]}; |
|
4
|
|
|
|
|
262
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |