1package String::Multibyte::ShiftJIS;
2
3use vars qw($VERSION);
4$VERSION = '1.12';
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__
45
46=head1 NAME
47
48String::Multibyte::ShiftJIS - internally used by String::Multibyte
49for Shift-JIS
50
51=head1 SYNOPSIS
52
53    use String::Multibyte;
54
55    $sjis = String::Multibyte->new('ShiftJIS');
56    $sjis_length = $sjis->length($sjis_string);
57
58=head1 DESCRIPTION
59
60C<String::Multibyte::ShiftJIS> is used for manipulation of strings
61in Shift-JIS family encodings.
62
63Byte range of single-byte characters:
64C<0x00..0x7F> and C<0xA1..0xDF>.
65
66Leading byte range of double-byte characters:
67C<0x81..0x9F> and C<0xE0..0xFC>.
68
69Trailing byte range of double-byte characters:
70C<0x40..0x7E> and C<0x80..0xFC>.
71
72Character order (invalid code points are excluded):
73C<0x00..0x7F>, C<0xA1..0xDF>, C<0x8140..0x9FFC>,
74C<0xE040..0xFCFC>.
75
76=head1 CAVEAT
77
78C<0xF040..0xFCFC> are included.
79
80C<0x80>, C<0xA0>, and C<0xFD..0xFF> are not supported.
81
82For Shift_JISX0213, row 8 of the plane 2, C<0xF09F..0xF0FC>,
83is simply arranged in the binary order
84(This module is not aware of the JIS X 0213 order).
85Then, row 1 (C<0xF040>) E<lt> row 8 (C<0xF09F>) E<lt> row 3 (C<0xF140>) ...
86
87=head1 SEE ALSO
88
89L<String::Multibyte>
90
91=cut
92