Parent Directory
|
Revision Log
|
Patch
| revision 1.1 by wakaba, Sun Sep 15 04:15:51 2002 UTC | revision 1.4 by wakaba, Mon Sep 16 06:35:16 2002 UTC | |
|---|---|---|
| # | Line 11 use strict; | Line 11 use strict; |
| 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 | ||
| # | Line 75 for my $f (0x30..0x7E) { | Line 75 for my $f (0x30..0x7E) { |
| 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; |
| # | Line 254 sub new_object { | Line 254 sub new_object { |
| 254 | Gdesignation => "\x42", ## F of designation or 0 | Gdesignation => "\x42", ## F of designation or 0 |
| 255 | Ginvoke => 1, | Ginvoke => 1, |
| 256 | }, | }, |
| 257 | undef_char => ["\x3F", {type => 'G94', charset => 'B'}], | |
| 258 | use_revision => 1, ## Output IRR | use_revision => 1, ## Output IRR |
| 259 | }; | }; |
| 260 | \%C; | \%C; |
| # | Line 295 sub iso2022_to_internal ($;\%) { | Line 296 sub iso2022_to_internal ($;\%) { |
| 296 | ((??{ $_CHARS_to_RANGE{'b'.$C->{$C->{GL}}->{chars}} | ((??{ $_CHARS_to_RANGE{'b'.$C->{$C->{GL}}->{chars}} |
| 297 | . qq/{$C->{G3}->{dimension},$C->{G3}->{dimension}}/ })) | . qq/{$C->{G3}->{dimension},$C->{G3}->{dimension}}/ })) |
| 298 | ||
| 299 | |((??{ $C->{$C->{CL}}->{r_LS0}||'(?!)' })) ## GL = G0 | ## Locking shift |
| 300 | |((??{ $C->{$C->{CL}}->{r_LS1}||'(?!)' })) ## GL = G1 | |( \x1B[\x6E\x6F\x7C-\x7E] |
| 301 | |(??{ $C->{$C->{CL}}->{r_LS0}||'(?!)' }) | |
| 302 | |(??{ $C->{$C->{CL}}->{r_LS1}||'(?!)' }) | |
| 303 | ) | |
| 304 | ||
| 305 | ## Control sequence | ## Control sequence |
| 306 | |(??{ '(?:'.($C->{$C->{CR}}->{r_CSI}||'(?!)') | |(??{ '(?:'.($C->{$C->{CR}}->{r_CSI}||'(?!)') |
| # | Line 314 sub iso2022_to_internal ($;\%) { | Line 318 sub iso2022_to_internal ($;\%) { |
| 318 | ## Misc. sequence (SP, control, or broken data) | ## Misc. sequence (SP, control, or broken data) |
| 319 | |([\x00-\xFF]) | |([\x00-\xFF]) |
| 320 | }{ | }{ |
| 321 | my ($gl,$gr,$ss2,$ss3,$ls0,$ls1,$csi,$esc,$misc) | my ($gl,$gr,$ss2,$ss3,$ls,$csi,$esc,$misc) |
| 322 | = ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10); | = ($1,$2,$3,$4,$5,$6,$7,$8,$9); |
| 323 | $C->{_irr} = undef unless defined $esc; | $C->{_irr} = undef unless defined $esc; |
| 324 | ## GL graphic character | ## GL graphic character |
| 325 | if (defined $gl) { | if (defined $gl) { |
| # | Line 353 sub iso2022_to_internal ($;\%) { | Line 357 sub iso2022_to_internal ($;\%) { |
| 357 | $c = $c * $C->{G3}->{chars} + unpack ('C', $_) - $m; | $c = $c * $C->{G3}->{chars} + unpack ('C', $_) - $m; |
| 358 | } | } |
| 359 | chr ($C->{G3}->{ucs} + $c); | chr ($C->{G3}->{ucs} + $c); |
| ## Locking shifts | ||
| } elsif ($ls0) { | ||
| $C->{GL} = 'G0'; ''; | ||
| } elsif ($ls1) { | ||
| $C->{GL} = 'G1'; ''; | ||
| 360 | ## Escape sequence | ## Escape sequence |
| 361 | } elsif ($esc) { | } elsif ($esc) { |
| 362 | ## IRR (revision number) | ## IRR (revision number) |
| # | Line 434 sub iso2022_to_internal ($;\%) { | Line 433 sub iso2022_to_internal ($;\%) { |
| 433 | $C->{_irr} = undef; | $C->{_irr} = undef; |
| 434 | } | } |
| 435 | $esc; | $esc; |
| 436 | ## Locking shifts | |