File Coverage

blib/lib/Encode/JP/Mobile/ConvertPictogramSJIS.pm
Criterion Covered Total %
statement 25 25 100.0
branch 4 4 100.0
condition 12 12 100.0
subroutine 6 6 100.0
pod n/a
total 47 47 100.0


line stmt bran cond sub pod time code
1             package Encode::JP::Mobile::ConvertPictogramSJIS;
2 24     24   132 use strict;
  24         47  
  24         941  
3 24     24   137 use warnings;
  24         45  
  24         688  
4 24     24   125 use Encode::Alias;
  24         45  
  24         4737  
5              
6             # sjis
7             define_alias('x-sjis-imode' => 'x-sjis-docomo');
8             define_alias('x-sjis-ezweb-auto' => 'x-sjis-kddi-auto');
9             define_alias('x-sjis-airedge' => 'x-sjis-airh');
10             define_alias('x-sjis-vodafone' => 'x-sjis-softbank');
11             define_alias('x-sjis-vodafone-auto' => 'x-sjis-softbank-auto');
12              
13             # backward compatiblity
14             define_alias('shift_jis-imode' => 'x-sjis-imode');
15             define_alias('shift_jis-kddi-auto' => 'x-sjis-kddi-auto');
16             define_alias('shift_jis-airedge' => 'x-sjis-airh');
17             define_alias('shift_jis-docomo' => 'x-sjis-imode');
18             define_alias('shift_jis-ezweb' => 'x-sjis-kddi');
19             define_alias('shift_jis-ezweb-auto' => 'x-sjis-kddi-auto');
20             define_alias('shift_jis-airh' => 'x-sjis-airh');
21              
22              
23             define_alias('shift_jis-softbank' => 'x-sjis-softbank');
24             define_alias('shift_jis-vodafone' => 'x-sjis-vodafone');
25              
26 24     24   142 no strict 'refs';
  24         52  
  24         10530  
27             for my $carrier (qw/docomo softbank softbank-auto kddi-auto airh/) {
28             my $pkg = "Encode::JP::Mobile::_ConvertPictogramSJIS${carrier}";
29             @{"$pkg\::ISA"} = 'Encode::Encoding';
30             $pkg->Define("x-sjis-$carrier");
31              
32             *{"$pkg\::decode"} = sub ($$;$) {
33 111     111   67022 my($self, $char, $check) = @_;
34 111         573 my $str = Encode::decode("x-sjis-$carrier-raw", $char);
35 111 100 100     1957 $_[1] = $str if $check and !ref $check and !( $check & Encode::LEAVE_SRC );
      100        
36 111         328 $str;
37             };
38              
39             *{"$pkg\::encode"} = sub ($$;$) {
40 132     132   30608 my($self, $str, $check) = @_;
41              
42 132         412 my $utf8_encoding = "x-utf8-$carrier";
43 132         323 $utf8_encoding =~ s/-auto$//;
44 132         250 $utf8_encoding =~ s/-airh$/-docomo/;
45              
46 132         354 $str = Encode::encode($utf8_encoding, $str, $check);
47 132         3250 Encode::_utf8_on($str);
48 132         426 $str = Encode::encode("x-sjis-${carrier}-raw", $str, $check);
49              
50 132 100 100     2403 $_[1] = $str if $check and !ref $check and !( $check & Encode::LEAVE_SRC );
      100        
51 132         374 $str;
52             }
53             }
54              
55              
56              
57             1;
58