| 1 | package Encode::JP::Mobile::UnicodeEmoji; | ||
| 2 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use base qw(Encode::Encoding); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use Encode::Alias; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 2 | ▶ | use Encode qw(:fallbacks); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 0 | ▶ | use Encode::JP::Mobile; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 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__ | ||