| 11 |
use vars qw(%CHARSET $VERSION); |
use vars qw(%CHARSET $VERSION); |
| 12 |
$VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
$VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
| 13 |
use base qw(Encode::Encoding); |
use base qw(Encode::Encoding); |
| 14 |
__PACKAGE__->Define (qw/iso-2022 iso2022/); |
__PACKAGE__->Define (qw/iso-2022 iso2022 2022 cp2022/); |
| 15 |
|
|
| 16 |
### --- Intialization |
### --- Intialization |
| 17 |
|
|
| 75 |
} |
} |
| 76 |
for my $f (0x30..0x5F, 0x7E) { |
for my $f (0x30..0x5F, 0x7E) { |
| 77 |
my $F = pack 'C', $f; |
my $F = pack 'C', $f; |
| 78 |
for ('', '!', '"', '#') { |
for ('', '!', '"', '#', ' ') { |
| 79 |
$CHARSET{G94n}->{ $_.$F }->{dimension} = 2; |
$CHARSET{G94n}->{ $_.$F }->{dimension} = 2; |
| 80 |
$CHARSET{G94n}->{ $_.$F }->{chars} = 94; |
$CHARSET{G94n}->{ $_.$F }->{chars} = 94; |
| 81 |
$CHARSET{G94n}->{ $_.$F }->{ucs} = |
$CHARSET{G94n}->{ $_.$F }->{ucs} = |
| 82 |
({'' => 0xE9F6C0}->{ $_ }||0) + 94*94 * ($f-0x30); |
({'' => 0xE9F6C0}->{ $_ }||0) + 94*94 * ($f-0x30); |
| 83 |
## BUG: 94^n DRCSes with I byte have no mapping area |
## BUG: 94^n sets with I byte have no mapping area |
| 84 |
|
|
| 85 |
$CHARSET{G96n}->{ $_.$F }->{dimension} = 2; |
$CHARSET{G96n}->{ $_.$F }->{dimension} = 2; |
| 86 |
$CHARSET{G96n}->{ $_.$F }->{chars} = 96; |
$CHARSET{G96n}->{ $_.$F }->{chars} = 96; |
| 295 |
((??{ $_CHARS_to_RANGE{'b'.$C->{$C->{GL}}->{chars}} |
((??{ $_CHARS_to_RANGE{'b'.$C->{$C->{GL}}->{chars}} |
| 296 |
. qq/{$C->{G3}->{dimension},$C->{G3}->{dimension}}/ })) |
. qq/{$C->{G3}->{dimension},$C->{G3}->{dimension}}/ })) |
| 297 |
|
|
| 298 |
|((??{ $C->{$C->{CL}}->{r_LS0}||'(?!)' })) ## GL = G0 |
## Locking shift |
| 299 |
|((??{ $C->{$C->{CL}}->{r_LS1}||'(?!)' })) ## GL = G1 |
|( \x1B[\x6E\x6F\x7C-\x7E] |
| 300 |
|
|(??{ $C->{$C->{CL}}->{r_LS0}||'(?!)' }) |
| 301 |
|
|(??{ $C->{$C->{CL}}->{r_LS1}||'(?!)' }) |
| 302 |
|
) |
| 303 |
|
|
| 304 |
## Control sequence |
## Control sequence |
| 305 |
|(??{ '(?:'.($C->{$C->{CR}}->{r_CSI}||'(?!)') |
|(??{ '(?:'.($C->{$C->{CR}}->{r_CSI}||'(?!)') |
| 317 |
## Misc. sequence (SP, control, or broken data) |
## Misc. sequence (SP, control, or broken data) |
| 318 |
|([\x00-\xFF]) |
|([\x00-\xFF]) |
| 319 |
}{ |
}{ |
| 320 |
my ($gl,$gr,$ss2,$ss3,$ls0,$ls1,$csi,$esc,$misc) |
my ($gl,$gr,$ss2,$ss3,$ls,$csi,$esc,$misc) |
| 321 |
= ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10); |
= ($1,$2,$3,$4,$5,$6,$7,$8,$9); |
| 322 |
$C->{_irr} = undef unless defined $esc; |
$C->{_irr} = undef unless defined $esc; |
| 323 |
## GL graphic character |
## GL graphic character |
| 324 |
if (defined $gl) { |
if (defined $gl) { |
| 356 |
$c = $c * $C->{G3}->{chars} + unpack ('C', $_) - $m; |
$c = $c * $C->{G3}->{chars} + unpack ('C', $_) - $m; |
| 357 |
} |
} |
| 358 |
chr ($C->{G3}->{ucs} + $c); |
chr ($C->{G3}->{ucs} + $c); |
|
## Locking shifts |
|
|
} elsif ($ls0) { |
|
|
$C->{GL} = 'G0'; ''; |
|
|
} elsif ($ls1) { |
|
|
$C->{GL} = 'G1'; ''; |
|
| 359 |
## Escape sequence |
## Escape sequence |
| 360 |
} elsif ($esc) { |
} elsif ($esc) { |
| 361 |
## IRR (revision number) |
## IRR (revision number) |
| 432 |
$C->{_irr} = undef; |
$C->{_irr} = undef; |
| 433 |
} |
} |
| 434 |
$esc; |
$esc; |
| 435 |
|
## Locking shifts |
| 436 |
|
} elsif ($ls) { |
| 437 |
|
if ($ls eq $C->{$C->{CL}}->{LS0}) { |
| 438 |
|
$C->{GL} = 'G0'; ''; |
| 439 |
|
} elsif ($ls eq $C->{$C->{CL}}->{LS1}) { |
| 440 |
|
$C->{GL} = 'G1'; ''; |
| 441 |
|
} elsif ($ls =~ /\x1B([\x6E\x6F])/) { |
| 442 |
|
$C->{GL} = {"\x6E"=>2, "\x6F"=>3}->{$1}; ''; |
| 443 |
|
} elsif ($ls =~ /\x1B([\x7C-\x7E])/) { |
| 444 |
|
$C->{GR} = {"\x7E"=>1, "\x7D"=>2, "\x7C"=>3}->{$1}; ''; |
| 445 |
|
} |
| 446 |
## Control sequence |
## Control sequence |
| 447 |
} elsif ($csi) { |
} elsif ($csi) { |
| 448 |
$csi =~ tr/\xA0-\xFF/\x20-\x7F/d; |
$csi =~ tr/\xA0-\xFF/\x20-\x7F/d; |
| 564 |
my $c = $cc % 0x10000; |
my $c = $cc % 0x10000; |
| 565 |
$t = _i2g (chr((($c % 8836) / 94)+0x21).chr(($c % 94)+0x21), $C, |
$t = _i2g (chr((($c % 8836) / 94)+0x21).chr(($c % 94)+0x21), $C, |
| 566 |
type => 'G94n', |
type => 'G94n', |
| 567 |
charset_id => 'P'.int(($cc / 0x10000) - 0x7042).int($c / 8836), |
charset_id => 'P'.int(($cc / 0x10000) - 0x7042).'_'.int($c / 8836), |
| 568 |
charset => $C->{private_set}->{G94n}->[ ($cc / 0x10000) - 0x7042 ] |
charset => $C->{private_set}->{G94n}->[ ($cc / 0x10000) - 0x7042 ] |
| 569 |
->[ $c / 8836 ]); |
->[ $c / 8836 ]); |
| 570 |
} |
} |