1 package Encode::JP::JIS7;
4 our $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
7 for my $name ('7bit-jis', 'iso-2022-jp', 'iso-2022-jp-1'){
8 my $h2z = ($name eq '7bit-jis') ? 0 : 1;
9 my $jis0212 = ($name eq 'iso-2022-jp') ? 0 : 1;
11 $Encode::Encoding{$name} =
19 sub name { shift->{'Name'} }
21 sub new_sequence { $_[0] }
25 use Encode::CJKConstants qw(:all);
30 # decode is identical for all 2022 variants
35 my ($obj,$str,$chk) = @_;
36 my $residue = jis_euc(\$str);
38 $_[1] = $residue if $chk;
39 # use perlqq fallback for euc-jp -> utf8
40 return Encode::decode('euc-jp', $str, 0);
49 require Encode::JP::H2Z;
50 my ($obj, $utf8, $chk) = @_;
51 # empty the input string in the stack so perlio is ok
53 my ($h2z, $jis0212) = @$obj{qw(h2z jis0212)};
54 my $octet = Encode::encode('euc-jp', $utf8, 0) ;
55 $h2z and &Encode::JP::H2Z::h2z(\$octet);
56 euc_jis(\$octet, $jis0212);
66 ($RE{JIS_0212}|$RE{JIS_0208}|$RE{ISO_ASC}|$RE{JIS_KANA})
70 my ($esc, $chunk) = ($1, $2);
71 if ($esc !~ /$RE{ISO_ASC}/o) {
72 $chunk =~ tr/\x21-\x7e/\xa1-\xfe/;
73 if ($esc =~ /$RE{JIS_KANA}/o) {
74 $chunk =~ s/([\xa1-\xdf])/\x8e$1/og;
76 elsif ($esc =~ /$RE{JIS_0212}/o) {
77 $chunk =~ s/([\xa1-\xfe][\xa1-\xfe])/\x8f$1/og;
82 my ($residue) = ($$r_str =~ s/(\e.*)$//so);
90 ((?:$RE{EUC_C})+|(?:$RE{EUC_KANA})+|(?:$RE{EUC_0212})+)
94 ( $chunk =~ tr/\x8E//d ) ? $ESC{KANA} :
95 ( $chunk =~ tr/\x8F//d ) ? $ESC{JIS_0212} :
97 if ($esc eq $ESC{JIS_0212} && !$jis0212){
99 $chunk =~ tr/\xA1-\xFE/\x3F/;
101 $chunk =~ tr/\xA1-\xFE/\x21-\x7E/;
103 $esc . $chunk . $ESC{ASC};
107 (\Q$ESC{KANA}\E|\Q$ESC{JIS_0212}\E|\Q$ESC{JIS_0208}\E)/$1/gox;
117 Encode::JP::JIS7 -- internally used by Encode::JP