67 |
$CHARSET{G96n}->{ $_.$F }->{chars} = 96; |
$CHARSET{G96n}->{ $_.$F }->{chars} = 96; |
68 |
$CHARSET{G96n}->{ $_.$F }->{ucs} = |
$CHARSET{G96n}->{ $_.$F }->{ucs} = |
69 |
({'' => 0xF4C000}->{ $_ }||0) + 96*96 * ($f-0x30); |
({'' => 0xF4C000}->{ $_ }||0) + 96*96 * ($f-0x30); |
70 |
## BUG: 94^n DRCSes with I byte have no mapping area |
## BUG: 96^n DRCSes with I byte have no mapping area |
71 |
} |
} |
72 |
} |
} |
73 |
|
$CHARSET{G94n}->{"\x20\x40"}->{ucs} = 0x70460000; ## DRCS 94^2 04/00 |
74 |
|
$CHARSET{G94n}->{P4_0} = $CHARSET{G94n}->{"\x20\x40"}; |
75 |
|
|
76 |
for (0x60..0x6F) { |
for (0x60..0x6F) { |
77 |
my $F = pack 'C', $_; |
my $F = pack 'C', $_; |
78 |
## BUG: 9x^3 sets have no mapping area |
## BUG: 9x^3 sets have no mapping area |
109 |
$CHARSET{G94n}->{'B@'}->{dimension} = 2; ## JIS X 0208-1990 |
$CHARSET{G94n}->{'B@'}->{dimension} = 2; ## JIS X 0208-1990 |
110 |
$CHARSET{G94n}->{'B@'}->{chars} = 94; |
$CHARSET{G94n}->{'B@'}->{chars} = 94; |
111 |
$CHARSET{G94n}->{'B@'}->{ucs} = 0xE9F6C0 + 94*94*79; |
$CHARSET{G94n}->{'B@'}->{ucs} = 0xE9F6C0 + 94*94*79; |
112 |
|
|
113 |
|
## SJIS G3 mapping (JIS X 0213:2000 plane 2) |
114 |
|
$CHARSET{G94n}->{"\x50"}->{Csjis_kuE} = { # ku - 1 |
115 |
|
0xF0 => 7, 0xF1 => 3, 0xF2 => 11, 0xF3 => 13, 0xF4 => 77, |
116 |
|
0xF5 => 79, 0xF6 => 81, 0xF7 => 83, 0xF8 => 85, 0xF9 => 87, |
117 |
|
0xFA => 89, 0xFB => 91, 0xFC => 93, |
118 |
|
}; |
119 |
|
$CHARSET{G94n}->{"\x50"}->{Csjis_kuO} = { # ku - 1 |
120 |
|
0xF0 => 0, 0xF1 => 2, 0xF2 => 4, 0xF3 => 12, 0xF4 => 14, |
121 |
|
0xF5 => 78, 0xF6 => 80, 0xF7 => 82, 0xF8 => 84, 0xF9 => 86, |
122 |
|
0xFA => 88, 0xFB => 90, 0xFC => 92, |
123 |
|
}; |
124 |
|
$CHARSET{G94n}->{"\x50"}->{Csjis_first} = { reverse ( |
125 |
|
%{ $CHARSET{G94n}->{"\x50"}->{Csjis_kuE} }, |
126 |
|
%{ $CHARSET{G94n}->{"\x50"}->{Csjis_kuO} }, |
127 |
|
)}; |
128 |
|
|
129 |
## -- Control character sets |
## -- Control character sets |
130 |
$CHARSET{C0}->{'@'}->{ucs} = 0x00; ## ISO/IEC 6429 C0 |
$CHARSET{C0}->{'@'}->{ucs} = 0x00; ## ISO/IEC 6429 C0 |
131 |
for ("\x40", "\x43", "\x44", "\x45", "\x46", "\x49", "\x4A", "\x4B", "\x4C") { |
for ("\x40", "\x43", "\x44", "\x45", "\x46", "\x49", "\x4A", "\x4B", "\x4C") { |
203 |
sub new_object { |
sub new_object { |
204 |
my %C; |
my %C; |
205 |
$C{bit} = 8; |
$C{bit} = 8; |
206 |
|
$C{coding_system} = $CODING_SYSTEM{"\x40"}; ## ISO/IEC 2022 |
207 |
$C{CL} = 'C0'; $C{CR} = 'C1'; $C{ESC_Fe} = 'C1'; |
$C{CL} = 'C0'; $C{CR} = 'C1'; $C{ESC_Fe} = 'C1'; |
208 |
$C{C0} = $CHARSET{C0}->{"\x40"}; ## ISO/IEC 6429:1991 C0 |
$C{C0} = $CHARSET{C0}->{"\x40"}; ## ISO/IEC 6429:1991 C0 |
209 |
$C{C1} = $CHARSET{C1}->{'64291991C1'}; ## ISO/IEC 6429:1991 C1 |
$C{C1} = $CHARSET{C1}->{'64291991C1'}; ## ISO/IEC 6429:1991 C1 |
213 |
$C{G1} = $CHARSET{G94}->{"\x7E"}; ## empty set |
$C{G1} = $CHARSET{G94}->{"\x7E"}; ## empty set |
214 |
$C{G2} = $CHARSET{G94}->{"\x7E"}; ## empty set |
$C{G2} = $CHARSET{G94}->{"\x7E"}; ## empty set |
215 |
$C{G3} = $CHARSET{G94}->{"\x7E"}; ## empty set |
$C{G3} = $CHARSET{G94}->{"\x7E"}; ## empty set |
|
$C{coding_system} = $CODING_SYSTEM{"\x40"}; ## ISO/IEC 2022 |
|
216 |
$C{option} = { |
$C{option} = { |
217 |
C1invoke_to_right => 0, ## C1 invoked to: (0: ESC Fe, 1: CR) |
C1invoke_to_right => 0, ## C1 invoked to: (0: ESC Fe, 1: CR) |
218 |
G94n_designate_long => 0, ## (1: ESC 02/04 02/08 04/00..02) |
G94n_designate_long => 0, ## (1: ESC 02/04 02/08 04/00..02) |
219 |
designate_to => { ## Designated G buffer (-1: not be outputed) |
designate_to => { ## Designated G buffer (-1: not to be outputed) |
220 |
C0 => { |
C0 => { |
221 |
default => 0, |
default => 0, |
222 |
}, |
}, |
240 |
default => -1, |
default => -1, |
241 |
}, |
}, |
242 |
}, |
}, |
243 |
|
fallback_from_ucs => 'replacement', |
244 |
|
## 'replacement' / 'perl' / 'sgml' / 'sgml-hex' / 'x-u-escaped' / 'code' |
245 |
|
## / 'quiet' / 'quiet+back' / 'quiet+warn' / 'quiet+back+warn' / 'croak' |
246 |
|
## / code |
247 |
|
final_to_set => { |
248 |
|
C0 => {}, C1 => {}, G94 => {}, G94n => {}, |
249 |
|
G96 => {}, G96n => {}, coding_system => {}, |
250 |
|
}, |
251 |
Ginvoke_by_single_shift => [0,0,0,0], ## Invoked by SS |
Ginvoke_by_single_shift => [0,0,0,0], ## Invoked by SS |
252 |
Ginvoke_to_left => [1,1,1,1], ## Which invoked to? (1: L, 0: R) |
Ginvoke_to_left => [1,1,1,1], ## Which invoked to? (1: L, 0: R) |
253 |
private_set => { ## Private set vs Final byte |
private_set => { ## Private set vs Final byte |
254 |
C0 => [], |
C0 => [], |
255 |
C1 => [], |
C1 => [], |
256 |
G94 => [], |
G94 => [], |
257 |
G94n => [[],[],[],[],[]], |
G94n => [[],[],[],[],["\x20\x40"]], |
258 |
G96 => [], |
G96 => [], |
259 |
#G96n => [], ## (not implemented) |
#G96n => [], ## (not implemented) |
260 |
U96n => [], ## mule-unicode sets |
U96n => [], ## mule-unicode sets |
272 |
\%C; |
\%C; |
273 |
} |
} |
274 |
|
|
275 |
1; |
sub new_object_sjis { |
276 |
__END__ |
my $C = &new_object; |
277 |
|
$C->{coding_system} = $CODING_SYSTEM{Csjis}; |
278 |
|
$C->{CR} = undef; |
279 |
|
$C->{GR} = 'G2'; ## 0xA1-0xDF |
280 |
|
$C->{G0} = $CHARSET{G94}->{J}; ## JIS X 0201:1997 Latin |
281 |
|
$C->{G1} = $CHARSET{G94n}->{"\x4F"}; ## JIS X 0213:2000 |
282 |
|
$C->{G2} = $CHARSET{G94}->{I}; ## JIS X 0201:1997 Katakana |
283 |
|
$C->{G3} = $CHARSET{G94n}->{"\x50"}; ## JIS X 0213:2000 plane 2 |
284 |
|
## Special code area (0xFD-0xFF) |
285 |
|
$C->{Gsmap} = {"\xA0" => "\x{F8F0}", "\xFD" => "\x{F8F1}", "\xFE" => "\x{F8F2}", "\xFF" => "\x{F8F3}"}; |
286 |
|
$C->{GsmapR} = {}; ## Reversed table |
287 |
|
$C->{option}->{undef_char_sjis} = "\x81\xAC"; |
288 |
|
$C; |
289 |
|
} |
290 |
|
|
291 |
|
our %FallbackFromUCS = ( |
292 |
|
perl => sub { my $c = $_[2]; sprintf '\x{%04X}', ord $c }, |
293 |
|
sgml => sub { my $c = $_[2]; sprintf '&#%d;', ord $c }, |
294 |
|
'sgml-hex' => sub { my $c = $_[2]; sprintf '&#x%04X;', ord $c }, |
295 |
|
'x-u-escaped' => sub { my $c = $_[2]; my $C = ord $c; sprintf $C > 0xFFFF ? '\U%08X' : '\u%04X', $C }, |
296 |
|
); |
297 |
|
|
298 |
|
sub fallback_escape ($$$;%) { |
299 |
|
my (undef, $C, $c, %option) = @_; |
300 |
|
my $f = $option{fallback_from_ucs} ? |
301 |
|
(ref ($option{fallback_from_ucs}) eq 'CODE' ? $option{fallback_from_ucs} : |
302 |
|
$FallbackFromUCS{$option{fallback_from_ucs}}): |
303 |
|
(ref ($C->{option}->{fallback_from_ucs}) eq 'CODE' ? $C->{option}->{fallback_from_ucs} : |
304 |
|
$FallbackFromUCS{$C->{option}->{fallback_from_ucs}}); |
305 |
|
if (ref $f) { |
306 |
|
return undef if $option{_recursive} <= -10; $option{_recursive}--; ## To avoid loop |
307 |
|
my $self = bless {}, __PACKAGE__; |
308 |
|
Encode::_utf8_on ($c); |
309 |
|
return &$f ($self, $C, $c, \%option); |
310 |
|
} |
311 |
|
undef; |
312 |
|
} |
313 |
|
|
314 |
=head1 AUTHORS |
=head1 AUTHORS |
315 |
|
|
316 |
Nanashi-san |
Nanashi-san <nanashi-san@nanashi.invalid> |
317 |
|
|
318 |
Wakaba <w@suika.fam.cx> |
Wakaba <w@suika.fam.cx> |
319 |
|
|
320 |
=head1 LICENSE |
=head1 LICENSE |
321 |
|
|
322 |
Copyright 2002 AUTHORS |
Copyright 2002 AUTHORS, all rights reserved. |
323 |
|
|
324 |
This library is free software; you can redistribute it |
This library is free software; you can redistribute it |
325 |
and/or modify it under the same terms as Perl itself. |
and/or modify it under the same terms as Perl itself. |
326 |
|
|
327 |
=cut |
=cut |
328 |
|
|
329 |
# $Date$ |
1; # $Date$ |
|
### Charset.pm ends here |
|