line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Entities::ConvertPictogramMobileJp; |
2
|
3
|
|
|
3
|
|
240590
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
99
|
|
3
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
124
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
5
|
3
|
|
|
3
|
|
1095
|
use Encode; |
|
3
|
|
|
|
|
12139
|
|
|
3
|
|
|
|
|
375
|
|
6
|
3
|
|
|
3
|
|
1708
|
use Encode::JP::Mobile; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Params::Validate; |
8
|
|
|
|
|
|
|
use HTML::Entities::ConvertPictogramMobileJp::KDDITABLE; |
9
|
|
|
|
|
|
|
use File::ShareDir qw/dist_file/; |
10
|
|
|
|
|
|
|
use base 'Exporter'; |
11
|
|
|
|
|
|
|
our @EXPORT = qw/convert_pictogram_entities/; |
12
|
|
|
|
|
|
|
use 5.008001; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub convert_pictogram_entities { |
15
|
|
|
|
|
|
|
validate(@_ => +{ |
16
|
|
|
|
|
|
|
mobile_agent => +{ |
17
|
|
|
|
|
|
|
callbacks => { |
18
|
|
|
|
|
|
|
'HTTP::MobileAgent or HTTP::MobileAttribute' => sub { |
19
|
|
|
|
|
|
|
my $pkg = ref $_[0]; |
20
|
|
|
|
|
|
|
$pkg && ( |
21
|
|
|
|
|
|
|
$_[0]->isa('HTTP::MobileAgent') || |
22
|
|
|
|
|
|
|
$_[0]->isa('HTTP::MobileAttribute') || |
23
|
|
|
|
|
|
|
$pkg =~ /^HTTP::MobileAttribute::Agent::/ |
24
|
|
|
|
|
|
|
) |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
html => 1, |
29
|
|
|
|
|
|
|
}); |
30
|
|
|
|
|
|
|
my %args = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $content = $args{html}; |
33
|
|
|
|
|
|
|
my $agent = $args{mobile_agent}; |
34
|
|
|
|
|
|
|
$content =~ s{(&\#x([A-Z0-9]+);)}{ |
35
|
|
|
|
|
|
|
if ($agent->is_softbank) { |
36
|
|
|
|
|
|
|
_convert_unicode('softbank', $2) |
37
|
|
|
|
|
|
|
} elsif ($agent->is_ezweb) { |
38
|
|
|
|
|
|
|
join '', map { _ezuni2tag($_) } |
39
|
|
|
|
|
|
|
map { unpack 'U*', $_ } |
40
|
|
|
|
|
|
|
split //, decode "x-utf8-kddi", |
41
|
|
|
|
|
|
|
encode( "x-utf8-kddi", chr( hex $2 ) ); |
42
|
|
|
|
|
|
|
} elsif ($agent->is_docomo) { |
43
|
|
|
|
|
|
|
if ($agent->is_foma) { |
44
|
|
|
|
|
|
|
_convert_unicode('docomo', $2); |
45
|
|
|
|
|
|
|
} else { |
46
|
|
|
|
|
|
|
_convert_sjis('docomo', $2); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} elsif ($agent->is_airh_phone) { |
49
|
|
|
|
|
|
|
_convert_sjis('docomo', $2); |
50
|
|
|
|
|
|
|
} else { |
51
|
|
|
|
|
|
|
$1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
}ge; |
54
|
|
|
|
|
|
|
$content; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _ezuni2tag { |
58
|
|
|
|
|
|
|
my $unicode = shift; |
59
|
|
|
|
|
|
|
if (my $number = _ezuni2number($unicode)) { |
60
|
|
|
|
|
|
|
sprintf '', $number; |
61
|
|
|
|
|
|
|
} else { |
62
|
|
|
|
|
|
|
sprintf '%X;', $unicode; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _ezuni2number { |
67
|
|
|
|
|
|
|
my $unicode = shift; |
68
|
|
|
|
|
|
|
$HTML::Entities::ConvertPictogramMobileJp::KDDITABLE::TABLE->{$unicode}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _convert_unicode { |
72
|
|
|
|
|
|
|
my ($carrier, $unihex) = @_; |
73
|
|
|
|
|
|
|
join '', map { sprintf '%X;', unpack 'U*', $_ } split //, |
74
|
|
|
|
|
|
|
decode "x-utf8-$carrier", encode( "x-utf8-$carrier", chr( hex $unihex ) ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _convert_sjis { |
78
|
|
|
|
|
|
|
my ($carrier, $unihex) = @_; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sprintf '%s;', uc unpack 'H*', encode("x-sjis-$carrier", chr(hex $unihex)); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
__END__ |