File Coverage

blib/lib/String/Multibyte/ShiftJIS.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package String::Multibyte::ShiftJIS;
2              
3 18     18   126 use vars qw($VERSION);
  18     1   26  
  18         4430  
  1         10  
  1         1  
  1         286  
4             $VERSION = '1.06';
5              
6             +{
7             charset => 'Shift-JIS',
8              
9             regexp => '(?:[\x00-\x7F\xA1-\xDF]|' .
10             '[\x81-\x9F\xE0-\xFC][\x40-\x7E\x80-\xFC])',
11              
12             cmpchar => sub {
13             length($_[0]) <=> length($_[1]) || $_[0] cmp $_[1];
14             },
15              
16             nextchar => sub {
17             my $ch = shift;
18             my $len = length $ch;
19             if ($len < 1 || 2 < $len) {
20             return undef;
21             }
22             elsif ($len == 1) {
23             return $ch eq "\x7F"
24             ? "\xA1"
25             : $ch eq "\xDF"
26             ? "\x81\x40"
27             : chr(ord($ch)+1);
28             }
29             else {
30             my($c,$d) = unpack('CC',$ch);
31             return $ch eq "\x9F\xFC"
32             ? "\xE0\x40"
33             : $ch eq "\xFC\xFC"
34             ? undef
35             : $d == 0xFC
36             ? chr($c+1)."\x40"
37             : $d == 0x7E
38             ? chr($c) ."\x80"
39             : pack('CC', $c, $d+1);
40             }
41             },
42             };
43              
44             __END__