| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=encoding utf-8 |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Encode::JP::Emoji::FB_EMOJI_TYPECAST - Emoji fallback for TypeCast emoji images |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Encode; |
|
10
|
|
|
|
|
|
|
use Encode::JP::Emoji; |
|
11
|
|
|
|
|
|
|
use Encode::JP::Emoji::FB_EMOJI_TYPECAST; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $image_base = 'http://example.com/images/emoticons/'; |
|
14
|
|
|
|
|
|
|
$Encode::JP::Emoji::FB_EMOJI_TYPECAST::IMAGE_BASE = $image_base; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# DoCoMo Shift_JIS octets |
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
my $sun = "\xF8\x9F"; |
|
19
|
|
|
|
|
|
|
Encode::from_to($sun, 'x-sjis-emoji-docomo', 'x-sjis-emoji-none', FB_EMOJI_TYPECAST()); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# KDDI(web) Shift_JIS octets |
|
22
|
|
|
|
|
|
|
# |
|
23
|
|
|
|
|
|
|
my $mouse = "\xF3\xA5"; |
|
24
|
|
|
|
|
|
|
Encode::from_to($mouse, 'x-sjis-emoji-kddiweb', 'x-sjis-emoji-none', FB_EMOJI_TYPECAST()); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# SoftBank UTF-8 string |
|
27
|
|
|
|
|
|
|
# |
|
28
|
|
|
|
|
|
|
my $heart = "\x{E20C}"; |
|
29
|
|
|
|
|
|
|
$heart = Encode::encode('x-sjis-e4u-none', $heart, FB_EMOJI_TYPECAST()); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Google UTF-8 octets |
|
32
|
|
|
|
|
|
|
# |
|
33
|
|
|
|
|
|
|
my $beer = "\xF3\xBE\xA6\x83"; |
|
34
|
|
|
|
|
|
|
$beer = Encode::decode('x-utf8-e4u-none', $beer, FB_EMOJI_TYPECAST()); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This module exports the following fallback function. |
|
39
|
|
|
|
|
|
|
Use this with C and C encodings |
|
40
|
|
|
|
|
|
|
which rejects any emojis. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 FB_EMOJI_TYPECAST() |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This function returns an C element for PC to display emoji images. |
|
45
|
|
|
|
|
|
|
Having conflicts with SoftBank encoding, KDDI(app) encoding is B recommended. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 $Encode::JP::Emoji::FB_EMOJI_TYPECAST::IMAGE_BASE |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This variable sets base URL to TypeCast emoji files. |
|
50
|
|
|
|
|
|
|
Download their C archive package from |
|
51
|
|
|
|
|
|
|
L. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Image files on Google Code Project Hosting, |
|
54
|
|
|
|
|
|
|
L, |
|
55
|
|
|
|
|
|
|
is directly used by default. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
TypeCast Emoji Icon Images by Six Apart Ltd is licensed |
|
58
|
|
|
|
|
|
|
under a Creative Commons Attribution 2.1 Japan License. |
|
59
|
|
|
|
|
|
|
Permissions beyond the scope of this license may be available at |
|
60
|
|
|
|
|
|
|
L. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 LINKS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over 4 |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * Subversion Trunk |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * Project Hosting on Google Code |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * Google Groups and some Japanese documents |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
L |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * RT: CPAN request tracker |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
L |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * Search CPAN |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Yusuke Kawasaki, L |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
L |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright 2009 Yusuke Kawasaki, all rights reserved. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
package Encode::JP::Emoji::FB_EMOJI_TYPECAST; |
|
107
|
5
|
|
|
5
|
|
1171097
|
use strict; |
|
|
5
|
|
|
|
|
16
|
|
|
|
5
|
|
|
|
|
233
|
|
|
108
|
5
|
|
|
5
|
|
30
|
use warnings; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
209
|
|
|
109
|
5
|
|
|
5
|
|
44
|
use base 'Exporter'; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
474
|
|
|
110
|
5
|
|
|
5
|
|
30
|
use Carp; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
347
|
|
|
111
|
5
|
|
|
5
|
|
26
|
use Encode (); |
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
87
|
|
|
112
|
5
|
|
|
5
|
|
29
|
use Encode::JP::Emoji; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
99
|
|
|
113
|
5
|
|
|
5
|
|
27
|
use Encode::JP::Emoji::Property; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
496
|
|
|
114
|
5
|
|
|
5
|
|
11473
|
use Encode::JP::Emoji::FB_EMOJI_TEXT; |
|
|
5
|
|
|
|
|
5660
|
|
|
|
5
|
|
|
|
|
1673
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
119
|
|
|
|
|
|
|
FB_EMOJI_TYPECAST |
|
120
|
|
|
|
|
|
|
); |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub loaded_path { |
|
123
|
0
|
|
|
0
|
0
|
0
|
my $path = $INC{join('/'=>split('::'=>__PACKAGE__)).'.pm'}; |
|
124
|
0
|
|
|
|
|
0
|
$path =~ s#[^\/\:\\]+$##; |
|
125
|
0
|
|
|
|
|
0
|
$path; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
our $IMAGE_BASE = 'http://typecastmobile.googlecode.com/svn/trunk/static/images/emoticons/'; |
|
129
|
|
|
|
|
|
|
our $HTML_FORMAT = ' '; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $DATA_FILE = 'Encode/JP/Emoji/FB_EMOJI_TYPECAST/Emoticon.pl'; |
|
132
|
|
|
|
|
|
|
my $DATA_CACHE; |
|
133
|
|
|
|
|
|
|
sub data { |
|
134
|
52
|
100
|
|
52
|
0
|
167
|
return $DATA_CACHE if ref $DATA_CACHE; |
|
135
|
4
|
|
|
|
|
10904
|
$DATA_CACHE = do $DATA_FILE; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
my $ascii = Encode::find_encoding('us-ascii'); |
|
139
|
|
|
|
|
|
|
my $utf8 = Encode::find_encoding('utf8'); |
|
140
|
|
|
|
|
|
|
my $docomo = Encode::find_encoding('x-utf8-e4u-docomo'); |
|
141
|
|
|
|
|
|
|
my $mixed = Encode::find_encoding('x-utf8-e4u-mixed'); |
|
142
|
|
|
|
|
|
|
my $none = Encode::find_encoding('x-utf8-e4u-none'); |
|
143
|
|
|
|
|
|
|
my $fbtext = FB_EMOJI_TEXT(); |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub FB_EMOJI_TYPECAST { |
|
146
|
52
|
|
33
|
52
|
1
|
19277
|
my $fb = shift || $fbtext; |
|
147
|
|
|
|
|
|
|
sub { |
|
148
|
52
|
|
|
52
|
|
17868
|
my $code = shift; |
|
149
|
52
|
|
|
|
|
187
|
my $chr = chr $code; # Native UTF-8 string |
|
150
|
52
|
|
|
|
|
67
|
my $dcode = 0; |
|
151
|
52
|
100
|
|
|
|
390
|
if ($chr =~ /\p{InEmojiDoCoMo}/) { |
|
|
|
50
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# docomo emoji |
|
153
|
13
|
|
|
|
|
680
|
$dcode = $code; |
|
154
|
|
|
|
|
|
|
} elsif ($chr =~ /\p{InEmojiAny}/) { |
|
155
|
|
|
|
|
|
|
# others emoji to docomo emoji |
|
156
|
39
|
|
|
|
|
10262
|
my $moct = $utf8->encode(chr $code, $fb); # Native UTF-8 octets |
|
157
|
39
|
|
|
|
|
184
|
my $gstr = $mixed->decode($moct, $fb); # Google UTF-8 string |
|
158
|
39
|
|
|
|
|
8847
|
my $doct = $docomo->encode($gstr, $fb); # DoCoMo UTF-8 octets |
|
159
|
39
|
|
|
|
|
3222
|
my $dstr = $utf8->decode($doct, $fb); # DoCoMo UTF-8 string |
|
160
|
39
|
100
|
|
|
|
398
|
$dcode = ord $dstr if (1 == length $dstr); |
|
161
|
|
|
|
|
|
|
} |
|
162
|
52
|
|
|
|
|
180
|
my $data = data(); |
|
163
|
52
|
|
|
|
|
249
|
my $hex = sprintf '%04X' => $dcode; |
|
164
|
52
|
100
|
|
|
|
200
|
unless (exists $data->{docomo}->{$hex}) { |
|
165
|
10
|
|
|
|
|
74
|
my $aoct = $ascii->encode(chr $code, $fb); # force fallback |
|
166
|
10
|
|
|
|
|
4274
|
return $utf8->decode($aoct, $fb); # UTF-8 string |
|
167
|
|
|
|
|
|
|
} |
|
168
|
42
|
|
|
|
|
87
|
my $file = $data->{docomo}->{$hex}; |
|
169
|
42
|
|
|
|
|
259
|
my $name = $none->encode(chr $code, $fbtext); # emoji name |
|
170
|
42
|
|
|
|
|
19502
|
$name = $utf8->decode($name, $fb); # UTF-8 string |
|
171
|
42
|
|
|
|
|
561
|
sprintf $HTML_FORMAT => $IMAGE_BASE, $file, $name; |
|
172
|
52
|
|
|
|
|
488
|
}; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# This file was written in UTF-8 |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |