line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Encode::JP::Mobile::Charnames; |
2
|
24
|
|
|
24
|
|
107572
|
use strict; |
|
24
|
|
|
|
|
49
|
|
|
24
|
|
|
|
|
1111
|
|
3
|
24
|
|
|
24
|
|
132
|
use warnings; |
|
24
|
|
|
|
|
52
|
|
|
24
|
|
|
|
|
664
|
|
4
|
24
|
|
|
24
|
|
126
|
use bytes (); |
|
24
|
|
|
|
|
48
|
|
|
24
|
|
|
|
|
458
|
|
5
|
24
|
|
|
24
|
|
23345
|
use File::ShareDir 'dist_file'; |
|
24
|
|
|
|
|
181620
|
|
|
24
|
|
|
|
|
2299
|
|
6
|
24
|
|
|
24
|
|
271
|
use Carp; |
|
24
|
|
|
|
|
50
|
|
|
24
|
|
|
|
|
1905
|
|
7
|
24
|
|
|
24
|
|
1991
|
use Encode; |
|
24
|
|
|
|
|
11885
|
|
|
24
|
|
|
|
|
2449
|
|
8
|
24
|
|
|
24
|
|
2397
|
use Encode::JP::Mobile ':props'; |
|
24
|
|
|
|
|
58
|
|
|
24
|
|
|
|
|
11392
|
|
9
|
24
|
|
|
24
|
|
176
|
use Encode::JP::Mobile::Character; |
|
24
|
|
|
|
|
61
|
|
|
24
|
|
|
|
|
821
|
|
10
|
|
|
|
|
|
|
|
11
|
24
|
|
|
24
|
|
136
|
use base qw( Exporter ); |
|
24
|
|
|
|
|
54
|
|
|
24
|
|
|
|
|
4000
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( unicode2name unicode2name_en vianame ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $name2unicode; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
# re.pm clobbers $_ in 5.14.0 ~ 5.16.0 |
18
|
|
|
|
|
|
|
# and charnames.pm requires re.pm |
19
|
|
|
|
|
|
|
# ref. https://github.com/mirrors/perl/commit/48895a0d |
20
|
|
|
|
|
|
|
BEGIN { |
21
|
24
|
|
|
24
|
|
65
|
local $_; |
22
|
24
|
|
|
|
|
38619
|
require charnames; |
23
|
24
|
|
|
|
|
389073
|
charnames->import(':full'); |
24
|
24
|
|
|
|
|
26686
|
*_def_translator = $^H{charnames} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub import { |
30
|
|
|
|
|
|
|
# for perl < 5.10 |
31
|
24
|
50
|
|
24
|
|
523
|
if ($charnames::hint_bits) { |
32
|
0
|
|
|
|
|
0
|
$^H |= $charnames::hint_bits; |
33
|
|
|
|
|
|
|
} |
34
|
24
|
|
|
|
|
136
|
$^H{charnames} = \&_translator; |
35
|
24
|
|
|
|
|
8424
|
__PACKAGE__->export_to_level(1, @_); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _translator { |
39
|
12
|
100
|
|
12
|
|
915
|
if ( $^H & $bytes::hint_bits ) { |
40
|
2
|
|
|
|
|
6
|
_bytes_translator(@_); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
10
|
|
|
|
|
30
|
_unicode_translator(@_); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _name2unicode () { |
48
|
8
|
100
|
|
8
|
|
278
|
return $name2unicode if $name2unicode; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
2
|
for my $carrier (qw/docomo kddi softbank/) { |
51
|
3
|
|
|
|
|
29
|
my $fname = dist_file( 'Encode-JP-Mobile', "${carrier}-table.pl" ); |
52
|
3
|
|
|
|
|
35707
|
my $dat = do $fname; |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
101
|
for my $row (@$dat) { |
55
|
1367
|
50
|
|
|
|
2779
|
next unless exists $row->{name}; |
56
|
1367
|
|
66
|
|
|
7131
|
$name2unicode->{$carrier}{$row->{name}} ||= hex $row->{unicode}; |
57
|
1367
|
100
|
|
|
|
2924
|
if ( exists $row->{name_en} ) { |
58
|
848
|
|
66
|
|
|
5598
|
$name2unicode->{$carrier}{$row->{name_en}} ||= hex $row->{unicode}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
11
|
return $name2unicode; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $re = qr/^(DoCoMo|KDDI|SoftBank) (.+)$/io; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _unicode_translator { |
70
|
10
|
|
|
10
|
|
16
|
my $name = shift; |
71
|
|
|
|
|
|
|
|
72
|
10
|
100
|
|
|
|
109
|
if ( my ( $carrier, $r_name ) = ( $name =~ $re ) ) { |
73
|
6
|
|
|
|
|
15
|
my $ret = _name2unicode->{lc($carrier)}{$r_name}; |
74
|
6
|
100
|
|
|
|
23
|
if ( defined $ret ) { |
75
|
4
|
|
|
|
|
339
|
return pack "U*", $ret; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
2
|
|
|
|
|
502
|
carp "unknown charnames: $r_name"; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
else { |
82
|
4
|
|
|
|
|
20
|
return _def_translator($name); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# pictograms are only in the above 0xFF area. |
87
|
|
|
|
|
|
|
sub _bytes_translator { |
88
|
2
|
|
|
2
|
|
5
|
my $name = shift; |
89
|
2
|
|
|
|
|
7
|
return _def_translator($name); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub vianame { |
93
|
3
|
|
|
3
|
1
|
8112
|
my $name = shift; |
94
|
3
|
100
|
|
|
|
131
|
croak "missing name" unless $name; |
95
|
|
|
|
|
|
|
|
96
|
2
|
50
|
|
|
|
31
|
if ( my ( $carrier, $r_name ) = ( $name =~ $re ) ) { |
97
|
2
|
|
66
|
|
|
11
|
return _name2unicode->{lc($carrier)}{$r_name} || carp "unknown charnames: $r_name"; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
else { |
100
|
0
|
|
|
|
|
0
|
return charnames::vianame($name); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# handling x-sjis-kddi-cp932-raw.see pod. |
105
|
|
|
|
|
|
|
sub _kddi_cp932toauto { |
106
|
10
|
|
|
10
|
|
14
|
my $code = shift; |
107
|
|
|
|
|
|
|
|
108
|
10
|
|
|
|
|
50
|
my $c = pack('U', $code); |
109
|
10
|
100
|
100
|
|
|
104
|
if ($c !~ /^\p{InKDDISoftBankConflicts}$/ && $c =~ /^\p{InKDDICP932Pictograms}$/) { |
110
|
2
|
|
|
|
|
13
|
return unpack 'U*', decode('x-sjis-kddi-auto-raw', encode('x-sjis-kddi-cp932-raw', $c)); |
111
|
|
|
|
|
|
|
} else { |
112
|
8
|
|
|
|
|
144
|
return $code; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub unicode2name { |
117
|
7
|
|
|
7
|
1
|
7584
|
my $code = shift; |
118
|
7
|
100
|
|
|
|
200
|
croak "missing code" unless $code; |
119
|
|
|
|
|
|
|
|
120
|
6
|
|
|
|
|
20
|
return Encode::JP::Mobile::Character->from_unicode(_kddi_cp932toauto($code))->name; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub unicode2name_en { |
124
|
5
|
|
|
5
|
1
|
3202
|
my $code = shift; |
125
|
5
|
100
|
|
|
|
145
|
croak "missing code" unless $code; |
126
|
|
|
|
|
|
|
|
127
|
4
|
|
|
|
|
12
|
return Encode::JP::Mobile::Character->from_unicode(_kddi_cp932toauto($code))->name_en; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
__END__ |