line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::ReplacePictogramMobileJp::Base; |
2
|
3
|
|
|
3
|
|
22
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
114
|
|
3
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
136
|
|
4
|
3
|
|
|
3
|
|
152
|
use base 'Exporter'; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
781
|
|
5
|
|
|
|
|
|
|
our @EXPORT = qw/unicode_property unicode_hex_cref filter img_localsrc/; |
6
|
3
|
|
|
3
|
|
19
|
use Params::Validate ':all'; |
|
3
|
|
|
|
|
35
|
|
|
3
|
|
|
|
|
806
|
|
7
|
3
|
|
|
3
|
|
5273
|
use Encode; |
|
3
|
|
|
|
|
58125
|
|
|
3
|
|
|
|
|
439
|
|
8
|
3
|
|
|
3
|
|
4724
|
use Encode::JP::Mobile ':props'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use File::ShareDir 'dist_file'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $property_for = +{ |
12
|
|
|
|
|
|
|
E => 'InKDDIPictograms', |
13
|
|
|
|
|
|
|
I => 'InDoCoMoPictograms', |
14
|
|
|
|
|
|
|
V => 'InSoftBankPictograms', |
15
|
|
|
|
|
|
|
}; |
16
|
|
|
|
|
|
|
sub unicode_property { |
17
|
|
|
|
|
|
|
my $carrier = shift; |
18
|
|
|
|
|
|
|
$_ =~ s/(\p{$property_for->{$carrier}})/callback(ord $1, $carrier)/ge; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub unicode_hex_cref { |
22
|
|
|
|
|
|
|
my $carrier = shift; |
23
|
|
|
|
|
|
|
$_ =~ s/([A-F0-9]{4});/callback(hex $1, $carrier)/ge; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _kddi_number2unicode_auto { |
27
|
|
|
|
|
|
|
my $number = shift; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $fname = |
30
|
|
|
|
|
|
|
File::ShareDir::dist_file( 'Encode-JP-Mobile', 'kddi-table.pl' ); |
31
|
|
|
|
|
|
|
my $dat = do $fname; |
32
|
|
|
|
|
|
|
for my $row (@$dat) { |
33
|
|
|
|
|
|
|
if ( $row->{number} == $number ) { |
34
|
|
|
|
|
|
|
return hex $row->{unicode_auto}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
return; # invalid number |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub img_localsrc { |
41
|
|
|
|
|
|
|
$_ =~ s{]+localsrc=["'](\d+)[^<>]+>}{ |
42
|
|
|
|
|
|
|
callback(_kddi_number2unicode_auto($1), 'E'); |
43
|
|
|
|
|
|
|
}ge; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub filter { |
47
|
|
|
|
|
|
|
my ($charset, $decode_by, $code) = @_; |
48
|
|
|
|
|
|
|
my $pkg = caller(0); |
49
|
|
|
|
|
|
|
no strict 'refs'; |
50
|
|
|
|
|
|
|
*{"$pkg\::$charset"} = sub { |
51
|
|
|
|
|
|
|
my $class = shift; |
52
|
|
|
|
|
|
|
validate( |
53
|
|
|
|
|
|
|
@_, |
54
|
|
|
|
|
|
|
+{ |
55
|
|
|
|
|
|
|
callback => { type => CODEREF }, |
56
|
|
|
|
|
|
|
html => { type => SCALAR }, |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
my %args = @_; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
local $_ = decode($decode_by, $args{html}, Encode::FB_XMLCREF); |
62
|
|
|
|
|
|
|
local *HTML::ReplacePictogramMobileJp::Base::callback = $args{callback}; |
63
|
|
|
|
|
|
|
local *{"$pkg\::callback"} = $args{callback}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$code->(); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$_ = encode($decode_by, $_); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$_; |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |