1package String::Multibyte::EUC_JP;
2
3use vars qw($VERSION);
4$VERSION = '1.12';
5
6+{
7    charset  => 'EUC-JP',
8
9    regexp   => '(?:[\x00-\x7F]|[\x8E\xA1-\xFE][\xA1-\xFE]|' .
10	'\x8F[\xA1-\xFE][\xA1-\xFE])',
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 || 3 < $len) {
20	    return;
21	}
22	elsif ($len == 1) {
23	    return $ch eq "\x7F"
24		? "\x8E\xA1"
25		: chr(ord($ch)+1);
26	}
27	elsif ($len == 2) {
28	    my($c,$d) = unpack('CC', $ch);
29	    return $ch eq "\x8E\xFE"
30		? "\xA1\xA1"
31		: $ch eq "\xFE\xFE"
32		    ? "\x8F\xA1\xA1"
33		    : $d == 0xFE
34			? chr($c+1)."\xA1"
35			: pack('CC', $c, $d+1);
36	}
37	else {
38	    return if 0x8F != ord $ch;
39	    my($b,$c,$d) = unpack('CCC',$ch);
40	    return $ch eq "\x8F\xFE\xFE"
41		? undef
42		: $d == 0xFE
43		    ? pack('CCC', 0x8F, $c+1, 0xA1)
44		    : pack('CCC', 0x8F, $c, $d+1);
45	}
46    },
47};
48
49__END__
50
51=head1 NAME
52
53String::Multibyte::EUC_JP - internally used by String::Multibyte
54for EUC-JP
55
56=head1 SYNOPSIS
57
58    use String::Multibyte;
59
60    $eucjp = String::Multibyte->new('EUC_JP');
61    $eucjp_length = $eucjp->length($eucjp_string);
62
63=head1 DESCRIPTION
64
65C<String::Multibyte::EUC_JP> is used for manipulation of strings
66in EUC-JP family encodings.
67
68Byte range of single-byte characters:
69C<0x00..0x7F>.
70
71First and second byte range of double-byte characters:
72C<0xA1..0xFE>.
73
74Legal byte range for two bytes preceded by SS3:
75C<0xA1..0xFE>.
76
77Character order (invalid code points are excluded):
78C<0x00..0x7F>, C<0x8EA1..0x8EFE>, C<0xA1A1..0xFEFE>,
79C<0x8FA1A1..0x8FFEFE>.
80
81                                       EUC-JP         EUC-JISX0213
82  1.  0x00..0x7F         C0/G0      ASCII          ASCII
83  2.  0x8EA1..0x8EFE       G2       JIS kana       JIS kana
84  3.  0xA1A1..0xFEFE       G1       JIS X 0208     JIS X 0213 plane-1
85  4.  0x8FA1A1..0x8FFEFE   G3       JIS X 0212     JIS X 0213 plane-2
86
87=head1 CAVEAT
88
89C1 controls other than SS2/SS3 (C<0x80..0x8D> and C<0x90..0x9E>)
90are not supported.
91
92Unassigned G2 (C<0x8EE0..0x8EFE>) are now included.
93
94=head1 SEE ALSO
95
96L<String::Multibyte>
97
98=cut
99