line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=encoding utf-8 |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Encode::JP::Emoji::FB_EMOJI_TEXT - Emoji fallback functions |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Encode; |
10
|
|
|
|
|
|
|
use Encode::JP::Emoji; |
11
|
|
|
|
|
|
|
use Encode::JP::Emoji::FB_EMOJI_TEXT; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# DoCoMo Shift_JIS octets fallback to "[SOON]" |
14
|
|
|
|
|
|
|
my $soon = "\xF9\x5B"; |
15
|
|
|
|
|
|
|
Encode::from_to($soon, 'x-sjis-e4u-docomo', 'x-sjis-e4u-kddiweb', FB_EMOJI_TEXT()); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# KDDI Shift_JIS octets fallback to "[霧]" |
18
|
|
|
|
|
|
|
my $fog = "\xF7\xB5"; |
19
|
|
|
|
|
|
|
Encode::from_to($fog, 'x-sjis-e4u-kddiweb', 'x-sjis-e4u-softbank3g', FB_EMOJI_TEXT()); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# SoftBank UTF-8 string fallback to "[ハムスター]" |
22
|
|
|
|
|
|
|
my $hamster = "\x{E524}"; |
23
|
|
|
|
|
|
|
my $softbank = Encode::encode('x-sjis-e4u-none', $hamster, FB_EMOJI_TEXT()); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Google UTF-8 octets fallback to "[クマ]" |
26
|
|
|
|
|
|
|
my $bear = "\xF3\xBE\x87\x81"; |
27
|
|
|
|
|
|
|
my $google = Encode::decode('x-utf8-e4u-none', $bear, FB_EMOJI_TEXT()); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This module exports the following fallback function. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 FB_EMOJI_TEXT() |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This returns emoji character name. |
36
|
|
|
|
|
|
|
Having conflicts with SoftBank encoding, KDDI(app) encoding is B recommended. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 BUGS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
C 2.22 or less would face a problem with fallback function. |
41
|
|
|
|
|
|
|
Use latest version of C, or use with C |
42
|
|
|
|
|
|
|
in C test directory of the package. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 AUTHOR |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Yusuke Kawasaki, L |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SEE ALSO |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
L |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 COPYRIGHT |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Copyright 2009-2010 Yusuke Kawasaki, all rights reserved. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
package Encode::JP::Emoji::FB_EMOJI_TEXT; |
59
|
2
|
|
|
2
|
|
1764
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
140
|
|
60
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
76
|
|
61
|
2
|
|
|
2
|
|
13
|
use base 'Exporter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
200
|
|
62
|
2
|
|
|
2
|
|
11
|
use Encode (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
41
|
|
63
|
2
|
|
|
2
|
|
13
|
use Encode::JP::Emoji::Mapping; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
64
|
2
|
|
|
2
|
|
12
|
use Encode::JP::Emoji::Property; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
622
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
our $VERSION = '0.60'; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
our @EXPORT = qw( |
69
|
|
|
|
|
|
|
FB_EMOJI_TEXT |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
our $TEXT_FORMAT = '[%s]'; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $ascii = Encode::find_encoding('us-ascii'); |
75
|
|
|
|
|
|
|
my $utf8 = Encode::find_encoding('utf8'); |
76
|
|
|
|
|
|
|
my $stand = Encode::find_encoding('x-utf8-e4u-unicode'); |
77
|
|
|
|
|
|
|
my $mixed = Encode::find_encoding('x-utf8-e4u-mixed'); |
78
|
|
|
|
|
|
|
my $check = Encode::FB_XMLCREF(); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub FB_EMOJI_TEXT { |
81
|
29
|
|
33
|
29
|
1
|
8239
|
my $fb = shift || $check; |
82
|
|
|
|
|
|
|
sub { |
83
|
29
|
|
|
29
|
|
43
|
my $code = shift; |
84
|
29
|
|
|
|
|
71
|
my $chr = chr $code; |
85
|
29
|
|
|
|
|
94
|
my $gcode; |
86
|
29
|
100
|
|
|
|
170
|
if ($chr =~ /\p{InEmojiGoogle}/) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# google emoji |
88
|
13
|
|
|
|
|
237
|
$gcode = $code; |
89
|
|
|
|
|
|
|
} elsif ($chr =~ /\p{InEmojiUnicode}/) { |
90
|
|
|
|
|
|
|
# unicode emoji |
91
|
3
|
|
|
|
|
14
|
my $moct = $utf8->encode(chr $code, $fb); # Mixed UTF-8 octets |
92
|
3
|
|
|
|
|
19
|
my $gstr = $stand->decode($moct, $fb); # Standard UTF-8 string |
93
|
3
|
50
|
|
|
|
14
|
$gcode = ord $gstr if (1 == length $gstr); |
94
|
|
|
|
|
|
|
} elsif ($chr =~ /\p{InEmojiMixed}/) { |
95
|
|
|
|
|
|
|
# others emoji |
96
|
13
|
|
|
|
|
506
|
my $moct = $utf8->encode(chr $code, $fb); # Mixed UTF-8 octets |
97
|
13
|
|
|
|
|
67
|
my $gstr = $mixed->decode($moct, $fb); # Google UTF-8 string |
98
|
13
|
50
|
|
|
|
56
|
$gcode = ord $gstr if (1 == length $gstr); |
99
|
|
|
|
|
|
|
} |
100
|
29
|
|
|
|
|
123
|
my $hex = sprintf '%04X' => $gcode; |
101
|
29
|
50
|
|
|
|
81
|
unless (exists $Encode::JP::Emoji::Mapping::CharnamesEmojiGoogle{$hex}) { |
102
|
0
|
|
|
|
|
0
|
my $aoct = $ascii->encode(chr $code, $fb); # force fallback |
103
|
0
|
|
|
|
|
0
|
return $utf8->decode($aoct, $fb); # UTF-8 string |
104
|
|
|
|
|
|
|
} |
105
|
29
|
|
|
|
|
50
|
my $name = $Encode::JP::Emoji::Mapping::CharnamesEmojiGoogle{$hex}; |
106
|
29
|
|
|
|
|
194
|
sprintf $TEXT_FORMAT => $name; |
107
|
29
|
|
|
|
|
270
|
}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# This file was written in UTF-8 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |