File Coverage

blib/lib/Encode/JP/Mobile/UnicodeEmoji.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             package Encode::JP::Mobile::UnicodeEmoji;
2 2     2   17380 use strict;
  2         3  
  2         184  
3 2     2   11 use warnings;
  2         4  
  2         230  
4 2     2   12 use base qw(Encode::Encoding);
  2         3  
  2         1675  
5 2     2   17156 use Encode::Alias;
  2         6  
  2         117  
6 2     2   9 use Encode qw(:fallbacks);
  2         4  
  2         409  
7 2     2   2354 use Encode::JP::Mobile;
  0            
  0            
8             use Encode::JP::Emoji;
9             use Encode::JP::Emoji::Property;
10             use Encode::MIME::Name;
11             our $VERSION = '0.012';
12              
13             __PACKAGE__->Define(qw(x-utf8-jp-mobile-unicode-emoji));
14             $Encode::MIME::Name::MIME_NAME_OF{'x-utf8-jp-mobile-unicode-emoji'} = 'UTF-8';
15              
16             sub _encoding1() { Encode::find_encoding('x-utf8-e4u-unicode') }
17             sub _encoding2() { Encode::find_encoding('x-utf8-e4u-docomo') }
18             sub _encoding3() { Encode::find_encoding('x-utf8-docomo') }
19              
20              
21             sub decode($$;$) {
22             my ($self, $str, $chk) = @_;
23              
24             $str = Encode::decode($self->_encoding1 => $str, $chk);
25             if ($str =~ /\p{InEmojiGoogle}/) {
26             $str = Encode::encode($self->_encoding2 => $str, $chk);
27             $str = Encode::decode($self->_encoding3 => $str, $chk);
28             }
29             $str;
30             }
31              
32             sub encode($$;$) {
33             my ( $self, $str, $chk ) = @_;
34              
35             if ($str =~ /\p{InEmojiDoCoMo}/) {
36             $str = Encode::encode($self->_encoding3 => $str, $chk);
37             $str = Encode::decode($self->_encoding2 => $str, $chk);
38             }
39             Encode::encode($self->_encoding1 => $str, $chk);
40             }
41              
42             1;
43             __END__