/[suikacvs]/perl/lib/Encode/ISO2022/SevenBit.pm
Suika

Contents of /perl/lib/Encode/ISO2022/SevenBit.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Sat Oct 5 05:01:24 2002 UTC (22 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.8: +115 -18 lines
2002-10-05  Nanashi-san

	* Table.pm: New module.
	(Commited by Wakaba <w@suika.fam.cx>.)

1 wakaba 1.1 =head1 NAME
2    
3     Encode::ISO2022::SevenBit --- Encode and decode of 7-bit ISO/IEC 2022
4     based encodings
5    
6     =head1 ENCODINGS
7    
8     =over 4
9    
10     =cut
11    
12     require 5.7.3;
13     use strict;
14     package Encode::ISO2022::SevenBit;
15     use vars qw($VERSION);
16 wakaba 1.9 $VERSION=do{my @r=(q$Revision: 1.8 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
17 wakaba 1.1 use base qw(Encode::Encoding);
18 wakaba 1.7 __PACKAGE__->Define (qw/iso-2022-7bit iso-2022-7 jis junet jis7
19     7bit-jis/);
20 wakaba 1.1 require Encode::ISO2022;
21    
22     sub encode ($$;$) {
23     my ($obj, $str, $chk) = @_;
24     $_[1] = '' if $chk;
25 wakaba 1.9 if (!defined $obj->{_encode_mapping} || $obj->{_encode_mapping}) {
26     require Encode::Table;
27     $str = Encode::Table::convert ($str, $obj->__encode_map,
28     -autoload => defined $obj->{_encode_mapping_autoload} ?
29     $obj->{_encode_mapping_autoload} : 1);
30     }
31 wakaba 1.1 $str = &Encode::ISO2022::internal_to_iso2022 ($str, $obj->__2022_encode);
32 wakaba 1.9 $str;
33 wakaba 1.1 }
34    
35     sub decode ($$;$) {
36     my ($obj, $str, $chk) = @_;
37     $_[1] = '' if $chk;
38 wakaba 1.9 $str = &Encode::ISO2022::iso2022_to_internal ($str, $obj->__2022_decode);
39     if (!defined $obj->{_decode_mapping} || $obj->{_decode_mapping}) {
40     require Encode::Table;
41     $str = Encode::Table::convert ($str, $obj->__decode_map,
42     -autoload => defined $obj->{_decode_mapping_autoload} ?
43     $obj->{_decode_mapping_autoload} : 1);
44     }
45     $str;
46 wakaba 1.1 }
47    
48     =item iso-2022-7bit
49    
50     ISO/IEC 2022 based 7-bit encoding using only G0
51 wakaba 1.7 (Alias: junet (emacsen), jis, jis7, iso-2022-7 (emacsen), 7bit-jis (perl))
52 wakaba 1.1
53     =cut
54    
55     sub __2022__common ($) {
56     my $C = Encode::ISO2022->new_object;
57     $C->{bit} = 7;
58     $C->{option}->{designate_to}->{G96}->{default} = 0;
59     $C->{option}->{designate_to}->{G96n}->{default} = 0;
60     $C;
61     }
62     sub __2022_encode ($) {
63     my $C = shift->__2022__common;
64 wakaba 1.4 $C->{GR} = undef;
65 wakaba 1.1 $C->{G1} = $Encode::ISO2022::CHARSET{G96}->{"\x7E"}; ## empty set
66     $C;
67     }
68     sub __2022_decode ($) {
69     my $C = shift->__2022__common;
70    
71     $C;
72     }
73 wakaba 1.9 sub __encode_map ($) {
74     [];
75     }
76     sub __decode_map ($) {
77     [];
78     }
79 wakaba 1.1
80     package Encode::ISO2022::SevenBit::JP;
81     use vars qw/@ISA/;
82     push @ISA, 'Encode::ISO2022::SevenBit';
83 wakaba 1.2 __PACKAGE__->Define (qw/iso-2022-jp junet-code japanese-iso-7bit csiso2022jp
84 wakaba 1.5 iso2022jp/);
85 wakaba 1.1
86     =item iso-2022-jp
87    
88     ISO/IEC 2022 based 7-bit encoding for Japanese.
89     Defined by Junet no tebiki, RFC 1468 and JIS X 0208:1997 Appendix 2.
90 wakaba 1.5 (Alias: junet-code, japanese-iso-7bit (emacsen), csISO2022JP (IANA))
91 wakaba 1.1
92     =cut
93    
94     sub __2022__common ($) {
95     my $C = Encode::ISO2022->new_object;
96     $C->{bit} = 7;
97     $C->{option}->{designate_to}->{C0}->{default} = -1;
98     $C->{option}->{designate_to}->{C0}->{"\x40"} = 0;
99     $C->{option}->{designate_to}->{C1}->{default} = -1;
100     $C->{option}->{designate_to}->{G94}->{default} = -1;
101     $C->{option}->{designate_to}->{G94n}->{default} = -1;
102     $C->{option}->{designate_to}->{G96}->{default} = -1;
103     $C->{option}->{designate_to}->{G96n}->{default} = -1;
104     $C->{option}->{designate_to}->{G94}->{"\x4A"} = 0; ## JIS X 0201 roman
105     $C->{option}->{designate_to}->{G94n}->{"\x40"} = 0; ## JIS X 0208-1978
106     $C->{option}->{designate_to}->{G94n}->{"\x42"} = 0; ## JIS X 0208-1983
107     $C->{option}->{designate_to}->{G94n}->{"\x42\x40"} = 0; ## JIS X 0208-1990
108     $C->{option}->{use_revision} = 0;
109     $C;
110     }
111     sub __2022_encode ($) {
112     my $C = shift->__2022__common;
113 wakaba 1.4 $C->{GR} = undef;
114 wakaba 1.1 $C->{C1} = $Encode::ISO2022::CHARSET{C1}->{"\x7E"}; ## empty set
115     $C->{G1} = $Encode::ISO2022::CHARSET{G96}->{"\x7E"}; ## empty set
116     $C;
117     }
118 wakaba 1.9 sub __encode_map ($) {
119     [qw/ucs_to_ascii ucs_to_jisx0208_1983 ucs_to_jisx0208_1990 ucs_to_jisx0208_1978 ucs_to_jisx0201_latin/];
120     }
121     sub __decode_map ($) {
122     [qw/jisx0208_1983_to_ucs jisx0208_1990_to_ucs jisx0208_1978_to_ucs jisx0201_latin_to_ucs/];
123     }
124 wakaba 1.1
125     package Encode::ISO2022::SevenBit::JP1978IRV;
126     use vars qw/@ISA/;
127     push @ISA, 'Encode::ISO2022::SevenBit::JP';
128 wakaba 1.2 __PACKAGE__->Define (qw/iso-2022-jp-1978-irv japanese-iso-7bit-1978-irv old-jis
129 wakaba 1.6 x-obsoleted-iso-2022-jp jis78/);
130 wakaba 1.1
131     =item iso-2022-jp-1978-irv
132    
133 wakaba 1.6 ISO/IEC 2022 based 7-bit encoding for Japanese,
134     using JIS X 0208-1978.
135     (Alias: japanese-iso-7bit-1978-irv (emacsen), old-jis (emacsen),
136     jis78)
137 wakaba 1.1
138     =cut
139    
140     sub __2022_encode ($) {
141     my $C = shift->__2022__common;
142 wakaba 1.4 $C->{GR} = undef;
143 wakaba 1.1 $C->{option}->{designate_to}->{G94}->{"\x4A"} = -1; ## JIS X 0201 roman
144     $C->{option}->{designate_to}->{G94n}->{"\x42"} = -1; ## JIS X 0208-1983
145     $C->{option}->{designate_to}->{G94n}->{"\x42\x40"} = -1; ## JIS X 0208-1990
146     $C;
147     }
148 wakaba 1.9 sub __encode_map ($) {
149     [qw/ucs_to_ascii ucs_to_jisx0208_1978 ucs_to_jisx0208_1983 ucs_to_jisx0208_1990 ucs_to_jisx0201_latin/];
150     }
151     sub __decode_map ($) {
152     [qw/jisx0208_1983_to_ucs jisx0208_1990_to_ucs jisx0208_1978_to_ucs jisx0201_latin_to_ucs/];
153     }
154 wakaba 1.1
155     package Encode::ISO2022::SevenBit::JP1;
156     use vars qw/@ISA/;
157     push @ISA, 'Encode::ISO2022::SevenBit::JP';
158 wakaba 1.8 __PACKAGE__->Define (qw/iso-2022-jp-1 iso2022jp-1/);
159 wakaba 1.1
160     =item iso-2022-jp-1
161    
162     ISO/IEC 2022 based 7-bit encoding for Japanese,
163 wakaba 1.8 defined by RFC 2237. (Alias: iso2022jp-1)
164 wakaba 1.1
165     =cut
166    
167     sub __2022__common ($) {
168     my $C = shift->SUPER::__2022__common;
169     $C->{option}->{designate_to}->{G94n}->{"\x44"} = 0; ## JIS X 0212-1990
170     $C->{option}->{designate_to}->{G94n}->{"\x42\x40"} = -1; ## JIS X 0208-1990
171     $C;
172     }
173 wakaba 1.9 sub __encode_map ($) {
174     [qw/ucs_to_ascii ucs_to_jisx0208_1983 ucs_to_jisx0212_1990 ucs_to_jisx0208_1978 ucs_to_jisx0201_latin/];
175     }
176     sub __decode_map ($) {
177     [qw/jisx0208_1983_to_ucs jisx0212_1990_to_ucs jisx0208_1978_to_ucs jisx0201_latin_to_ucs/];
178     }
179 wakaba 1.1
180     package Encode::ISO2022::SevenBit::JP3;
181     use vars qw/@ISA/;
182     push @ISA, 'Encode::ISO2022::SevenBit::JP';
183 wakaba 1.8 __PACKAGE__->Define (qw/iso-2022-jp-3 x-iso-2022-jp-3 iso2022jp-3
184 wakaba 1.9 jis0213/);
185 wakaba 1.1
186     =item iso-2022-jp-3
187    
188     ISO/IEC 2022 based 7-bit encoding for Japanese,
189     defined by JIS X 0213:2000 Appendix 2.
190 wakaba 1.8 (Alias: x-iso-2022-jp-3, iso2022jp-3, jis0213)
191 wakaba 1.1
192     =cut
193    
194     sub __2022__common ($) {
195     my $C = shift->SUPER::__2022__common;
196     $C->{option}->{designate_to}->{G94}->{"\x4A"} = -1; ## JIS X 0201 roman
197     $C->{option}->{designate_to}->{G94n}->{"\x40"} = -1; ## JIS X 0208-1978
198     $C->{option}->{designate_to}->{G94n}->{"\x42"} = 0; ## restricted JIS X 0213:2000 plane 1
199     $C->{option}->{designate_to}->{G94n}->{"\x42\x40"} = -1; ## JIS X 0208-1990
200     $C->{option}->{designate_to}->{G94n}->{"\x4F"} = 0; ## JIS X 0213:2000 plane 1
201     $C->{option}->{designate_to}->{G94n}->{"\x50"} = 0; ## JIS X 0213:2000 plane 2
202     $C;
203     }
204 wakaba 1.9 sub __encode_map ($) {
205     [qw/ucs_to_ascii ucs_to_jisx0213_2000_1 ucs_to_jisx0213_2000_2/];
206     }
207     sub __decode_map ($) {
208     [qw/jisx0213_2000_1_to_ucs jisx0212_0213_to_ucs jisx0208_1983_to_ucs jisx0208_1978_to_ucs jisx0201_latin_to_ucs/];
209     }
210    
211     package Encode::ISO2022::SevenBit::JP3Strict;
212     use vars qw/@ISA/;
213     push @ISA, 'Encode::ISO2022::SevenBit::JP3';
214     __PACKAGE__->Define (qw/iso-2022-jp-3-strict/);
215    
216     =item iso-2022-jp-3-strict
217    
218     ISO/IEC 2022 based 7-bit encoding for Japanese.
219     A subset of iso-2022-jp-3.
220     See <http://www.m17n.org/m17n2000_all_but_registration/proceedings/kawabata/jisx0213.html>.
221    
222     =cut
223    
224     sub __encode_map ($) {
225     [qw/ucs_to_ascii ucs_to_jisx0213_2000_1_esc_24_42 ucs_to_jisx0213_2000_1 ucs_to_jisx0213_2000_2/];
226     }
227    
228     package Encode::ISO2022::SevenBit::JP3Compatible;
229     use vars qw/@ISA/;
230     push @ISA, 'Encode::ISO2022::SevenBit::JP3';
231     __PACKAGE__->Define (qw/iso-2022-jp-3-compatible/);
232    
233     =item iso-2022-jp-3-compatible
234    
235     ISO/IEC 2022 based 7-bit encoding for Japanese.
236     See <http://www.m17n.org/m17n2000_all_but_registration/proceedings/kawabata/jisx0213.html>.
237    
238     =cut
239    
240     sub __encode_map ($) {
241     [qw/ucs_to_ascii ucs_to_jisx0208_1983 ucs_to_jisx0213_2000_1 ucs_to_jisx0213_2000_2/];
242     }
243 wakaba 1.1
244     package Encode::ISO2022::SevenBit::JP3Plane1;
245     use vars qw/@ISA/;
246     push @ISA, 'Encode::ISO2022::SevenBit::JP3';
247     __PACKAGE__->Define (qw/iso-2022-jp-3-plane1/);
248    
249     =item iso-2022-jp-3-plane1
250    
251     ISO/IEC 2022 based 7-bit encoding for Japanese,
252     defined by JIS X 0213:2000 Appendix 2.
253    
254     =cut
255    
256     sub __2022__common ($) {
257     my $C = shift->SUPER::__2022__common;
258     $C->{option}->{designate_to}->{G94n}->{"\x50"} = -1; ## JIS X 0213:2000 plane 2
259     $C;
260     }
261 wakaba 1.9 sub __encode_map ($) {
262     [qw/ucs_to_ascii ucs_to_jisx0213_2000_1/];
263     }
264     sub __decode_map ($) {
265     [qw/jisx0213_2000_1_to_ucs jisx0208_1983_to_ucs/];
266     }
267 wakaba 1.1
268     package Encode::ISO2022::SevenBit::SS2;
269     use vars qw/@ISA/;
270     push @ISA, 'Encode::ISO2022::SevenBit';
271 wakaba 1.3 __PACKAGE__->Define (qw/iso-2022-7bit-ss2 x-iso-2022-jp-2 iso-2022-ss2-7
272     jis_encoding csjisencoding/);
273 wakaba 1.1
274     =item iso-2022-7bit-ss2
275    
276     ISO/IEC 2022 based 7-bit encoding using SS2 for 96-charset
277 wakaba 1.3 (Alias: x-iso-2022-jp-2, iso-2022-ss2-7 (emacsen))
278 wakaba 1.1
279     =cut
280    
281     sub __2022__common ($) {
282     my $C = shift->SUPER::__2022__common;
283     $C->{option}->{designate_to}->{G96}->{default} = 2;
284     $C->{option}->{designate_to}->{G96n}->{default} = 2;
285     $C->{option}->{Ginvoke_by_single_shift}->[2] = 1;
286     $C;
287     }
288    
289     package Encode::ISO2022::SevenBit::JP2;
290     use vars qw/@ISA/;
291     push @ISA, 'Encode::ISO2022::SevenBit::SS2';
292 wakaba 1.8 __PACKAGE__->Define (qw/iso-2022-jp-2 csiso2022jp2 iso2022jp-2/);
293 wakaba 1.1
294     =item iso-2022-jp-2
295    
296     ISO/IEC 2022 based 7-bit multilingual encoding, defined by
297 wakaba 1.8 RFC 1554. A subset of iso-2022-7bit-ss2. (Alias: iso2022jp-2,
298     csISO2022JP2 (IANA))
299 wakaba 1.1
300     =cut
301    
302     sub __2022__common ($) {
303     my $C = shift->SUPER::__2022__common;
304     $C->{option}->{designate_to}->{C0}->{default} = -1;
305     $C->{option}->{designate_to}->{C0}->{"\x40"} = 0;
306     $C->{option}->{designate_to}->{C1}->{default} = -1;
307     $C->{C1} = $Encode::ISO2022::CHARSET{C1}->{"\x47"}; ## Minimum C1
308 wakaba 1.9 $C->{option}->{designate_to}->{C1}->{"\x47"} = -1;
309 wakaba 1.1 $C->{option}->{designate_to}->{G94}->{default} = -1;
310     $C->{option}->{designate_to}->{G94n}->{default} = -1;
311     $C->{option}->{designate_to}->{G96}->{default} = -1;
312     $C->{option}->{designate_to}->{G96n}->{default} = -1;
313     $C->{option}->{designate_to}->{G94}->{"\x4A"} = 0; ## JIS X 0201 roman
314 wakaba 1.9 for ("\x40", "\x41", "\x42", "\x43", "\x44") {
315 wakaba 1.1 $C->{option}->{designate_to}->{G94n}->{ $_ } = 0;
316     }
317     for ("\x41", "\x46") {
318     $C->{option}->{designate_to}->{G96}->{ $_ } = 2;
319     }
320     $C;
321     }
322     sub __2022_encode ($) {
323     my $C = shift->__2022__common;
324 wakaba 1.4 $C->{GR} = undef;
325 wakaba 1.1 $C->{C1} = $Encode::ISO2022::CHARSET{C1}->{"\x7E"}; ## empty set
326     $C->{G1} = $Encode::ISO2022::CHARSET{G96}->{"\x7E"}; ## empty set
327     $C;
328     }
329 wakaba 1.9 sub __encode_map ($) {
330     [qw/ucs_to_ascii ucs_to_jisx0208_1983 ucs_to_jisx0212_1990 ucs_to_gb2312_1980 ucs_to_ksx1001_1992 ucs_to_jisx0208_1978 ucs_to_isoiec8859_1 ucs_to_isoiec8859_7 ucs_to_jisx0201_latin/];
331     }
332     sub __decode_map ($) {
333     [qw/jisx0208_1983_to_ucs jisx0208_1978_to_ucs jisx0201_latin_to_ucs gb2312_1980_to_ucs ksx1001_1992_to_ucs isoiec8859_7_to_ucs/];
334     }
335 wakaba 1.1
336     package Encode::ISO2022::SevenBit::Lock;
337     use vars qw/@ISA/;
338     push @ISA, 'Encode::ISO2022::SevenBit';
339     __PACKAGE__->Define (qw/iso-2022-7bit-lock/);
340    
341     =item iso-2022-7bit-lock
342    
343     ISO/IEC 2022 based 7-bit encoding using G1 and locking-shift for 96-charset
344    
345     =cut
346    
347     sub __2022__common ($) {
348     my $C = shift->SUPER::__2022__common;
349     $C->{option}->{designate_to}->{G96}->{default} = 1;
350     $C->{option}->{designate_to}->{G96n}->{default} = 1;
351     $C;
352     }
353    
354 wakaba 1.3 package Encode::ISO2022::SevenBit::INT;
355     use vars qw/@ISA/;
356     push @ISA, 'Encode::ISO2022::SevenBit';
357     __PACKAGE__->Define (qw/iso-2022-int iso-2022-int-* iso-2022-int-2/);
358    
359     =item iso-2022-int
360    
361     ISO/IEC 2022 based 7-bit encoding using G1 and locking-shift for
362     KS X 1001 and 96-charset. See draft-ohta-text-encoding.
363     (Alias: iso-2022-int-*)
364    
365     =cut
366    
367     sub __2022__common ($) {
368     my $C = shift->SUPER::__2022__common;
369     $C->{option}->{designate_to}->{G96}->{default} = 1;
370     $C->{option}->{designate_to}->{G96n}->{default} = 1;
371     $C->{option}->{designate_to}->{G94n}->{"\x43"} = 1; ## KS X 1001
372     $C;
373     }
374     sub __2022_encode ($) {
375     my $C = shift->__2022__common;
376 wakaba 1.4 $C->{GR} = undef;
377 wakaba 1.3 $C->{C1} = $Encode::ISO2022::CHARSET{C1}->{"\x7E"}; ## empty set
378     $C->{G1} = $Encode::ISO2022::CHARSET{G96}->{"\x7E"}; ## empty set
379     $C;
380     }
381     sub __2022_decode ($) {
382     my $C = shift->__2022__common;
383     $C->{G1} = $Encode::ISO2022::CHARSET{G94n}->{"\x43"}; ## KS X 1001
384     $C;
385     }
386    
387 wakaba 1.1 package Encode::ISO2022::SevenBit::KR;
388     use vars qw/@ISA/;
389     push @ISA, 'Encode::ISO2022::SevenBit';
390 wakaba 1.2 __PACKAGE__->Define (qw/iso-2022-kr korean-iso-7bit csiso2022kr cp50225 kr2022/);
391 wakaba 1.1
392     =item iso-2022-kr
393    
394     An ISO/IEC 2022 based 7-bit encoding for Korean,
395 wakaba 1.2 defined by RFC 1557 (Alias: korean-iso-7bit (emacsen),
396     csISO2022KR (IANA), CP50225 (M$), KR2022)
397 wakaba 1.1
398     =cut
399    
400     sub __2022__common ($) {
401     my $C = shift->SUPER::__2022__common;
402     $C->{option}->{designate_to}->{C0}->{default} = -1;
403     $C->{option}->{designate_to}->{C0}->{"\x40"} = 0;
404     $C->{option}->{designate_to}->{C1}->{default} = -1;
405     $C->{option}->{designate_to}->{G94}->{default} = -1;
406     $C->{option}->{designate_to}->{G94n}->{default} = -1;
407     $C->{option}->{designate_to}->{G96}->{default} = -1;
408     $C->{option}->{designate_to}->{G96n}->{default} = -1;
409     $C->{option}->{designate_to}->{G94n}->{"\x43"} = 1; ## KS X 1001
410     $C;
411     }
412     sub __2022_encode ($) {
413     my $C = shift->__2022__common;
414 wakaba 1.4 $C->{GR} = undef;
415 wakaba 1.1 $C->{C1} = $Encode::ISO2022::CHARSET{C1}->{"\x7E"}; ## empty set
416     $C->{G1} = $Encode::ISO2022::CHARSET{G96}->{"\x7E"}; ## empty set
417     $C;
418     }
419     sub __2022_decode ($) {
420     my $C = shift->__2022__common;
421     $C->{G1} = $Encode::ISO2022::CHARSET{G94n}->{"\x43"}; ## KS X 1001
422     $C;
423     }
424 wakaba 1.9 sub __encode_map ($) {
425     [qw/ucs_to_ascii ksx1001_1992_to_ucs/];
426     }
427     sub __decode_map ($) {
428     [qw/ksx1001_1992_to_ucs/];
429     }
430 wakaba 1.1
431     package Encode::ISO2022::SevenBit::INT1;
432     use vars qw/@ISA/;
433     push @ISA, 'Encode::ISO2022::SevenBit';
434     __PACKAGE__->Define (qw/iso-2022-int-1/);
435    
436     =item iso-2022-int-1
437    
438     An ISO/IEC 2022 based 7-bit multilingual encoding,
439     defined by draft-ohta-text-encoding
440    
441     =cut
442    
443     sub __2022__common ($) {
444     my $C = shift->SUPER::__2022__common;
445     $C->{option}->{designate_to}->{C0}->{default} = -1;
446     $C->{option}->{designate_to}->{C0}->{"\x40"} = 0;
447     $C->{option}->{designate_to}->{C1}->{default} = -1;
448     $C->{option}->{designate_to}->{G94}->{default} = -1;
449     $C->{option}->{designate_to}->{G94n}->{default} = -1;
450     $C->{option}->{designate_to}->{G96}->{default} = -1;
451     $C->{option}->{designate_to}->{G96n}->{default} = -1;
452     $C->{option}->{designate_to}->{G94}->{"\x4A"} = 0; ## JIS X 0201 roman
453 wakaba 1.9 for ("\x40", "\x41", "\x42", "\x44") {
454 wakaba 1.1 $C->{option}->{designate_to}->{G94n}->{ $_ } = 0;
455     }
456     $C->{option}->{designate_to}->{G94n}->{"\x43"} = 1; ## KS X 1001
457     for ("\x41", "\x46") { ## ISO/IEC 8859-1,7
458     $C->{option}->{designate_to}->{G96}->{ $_ } = 1;
459     }
460     $C;
461     }
462     sub __2022_encode ($) {
463     my $C = shift->__2022__common;
464 wakaba 1.4 $C->{GR} = undef;
465 wakaba 1.1 $C->{C1} = $Encode::ISO2022::CHARSET{C1}->{"\x7E"}; ## empty set
466     $C->{G1} = $Encode::ISO2022::CHARSET{G96}->{"\x7E"}; ## empty set
467     $C;
468     }
469     sub __2022_decode ($) {
470     my $C = shift->__2022__common;
471     $C->{G1} = $Encode::ISO2022::CHARSET{G94n}->{"\x43"}; ## KS X 1001
472     $C;
473     }
474 wakaba 1.9 sub __encode_map ($) {
475     [qw/ucs_to_ascii ucs_to_isoiec8859_1 ucs_to_jisx0208_1983 ucs_to_jisx0212_1990 ucs_to_gb2312_1980 ucs_to_ksx1001_1992 ucs_to_isoiec8859_7 ucs_to_jisx0208_1978 ucs_to_jisx0201_latin/];
476     }
477     sub __decode_map ($) {
478     [qw/jisx0208_1983_to_ucs jisx0208_1978_to_ucs jisx0201_latin_to_ucs gb2312_1980_to_ucs ksx1001_1992_to_ucs isoiec8859_7_to_ucs/];
479     }
480 wakaba 1.1
481     package Encode::ISO2022::SevenBit::LockSS2;
482     use vars qw/@ISA/;
483     push @ISA, 'Encode::ISO2022::SevenBit';
484     __PACKAGE__->Define (qw/iso-2022-7bit-lock-ss2 iso-2022-cjk/);
485    
486     =item iso-2022-7bit-lock-ss2
487    
488     An ISO/IEC 2022 based 7-bit encoding. Mixture of ISO-2022-JP,
489     ISO-2022-KR, ISO-2022-CN. (Alias: iso-2022-cjk (emacsen))
490    
491     =cut
492    
493     sub __2022__common ($) {
494     my $C = shift->SUPER::__2022__common;
495     $C->{option}->{designate_to}->{G96}->{default} = 2;
496     $C->{option}->{designate_to}->{G96n}->{default} = 2;
497     $C->{option}->{designate_to}->{G94n}->{"\x41"} = 1; ## GB 2312
498     $C->{option}->{designate_to}->{G94n}->{"\x43"} = 1; ## KS X 1001
499     $C->{option}->{designate_to}->{G94n}->{"\x45"} = 1; ## ISO-IR 165
500     $C->{option}->{designate_to}->{G94n}->{"\x47"} = 1; ## CNS 11643 plane 1
501     $C->{option}->{designate_to}->{G94n}->{"\x48"} = 2; ## CNS 11643 plane 2
502     $C->{option}->{designate_to}->{G94n}->{"\x49"} = 3; ## CNS 11643 plane 3
503     $C->{option}->{designate_to}->{G94n}->{"\x4A"} = 3; ## CNS 11643 plane 4
504     $C->{option}->{designate_to}->{G94n}->{"\x4B"} = 3; ## CNS 11643 plane 5
505     $C->{option}->{designate_to}->{G94n}->{"\x4C"} = 3; ## CNS 11643 plane 6
506     $C->{option}->{designate_to}->{G94n}->{"\x4D"} = 3; ## CNS 11643 plane 7
507 wakaba 1.2 $C->{option}->{designate_to}->{G94n}->{P0_0} = 1; ## GB 12345
508     $C->{option}->{designate_to}->{G94n}->{P0_1} = 2; ## GB 7589
509     $C->{option}->{designate_to}->{G94n}->{P0_2} = 2; ## GB 13131
510     $C->{option}->{designate_to}->{G94n}->{P0_3} = 3; ## GB 7590
511     $C->{option}->{designate_to}->{G94n}->{P0_4} = 3; ## GB 13132
512 wakaba 1.1 $C;
513     }
514     sub __2022_decode ($) {
515     my $C = shift->__2022__common;
516     $C->{G1} = $Encode::ISO2022::CHARSET{G94n}->{"\x43"}; ## KS X 1001
517     $C;
518     }
519    
520     package Encode::ISO2022::SevenBit::CN;
521     use vars qw/@ISA/;
522     push @ISA, 'Encode::ISO2022::SevenBit';
523 wakaba 1.2 __PACKAGE__->Define (qw/iso-2022-cn chinese-iso-7bit iso2022cn-cns iso2022cn-gb/);
524 wakaba 1.1
525     =item iso-2022-cn
526    
527     An ISO/IEC 2022 based 7-bit encoding for Chinese,
528     defined by RFC 1922 (Alias: chinese-iso-7bit (emacsen))
529    
530     =cut
531    
532     sub __2022__common ($) {
533     my $C = shift->SUPER::__2022__common;
534     $C->{option}->{designate_to}->{C0}->{default} = -1;
535     $C->{option}->{designate_to}->{C0}->{"\x40"} = 0;
536     $C->{option}->{designate_to}->{C1}->{default} = -1;
537     $C->{option}->{designate_to}->{G94}->{default} = -1;
538     $C->{option}->{designate_to}->{G94n}->{default} = -1;
539     $C->{option}->{designate_to}->{G96}->{default} = -1;
540     $C->{option}->{designate_to}->{G96n}->{default} = -1;
541     $C->{option}->{designate_to}->{G94n}->{"\x41"} = 1; ## GB 2312
542     $C->{option}->{designate_to}->{G94n}->{"\x47"} = 1; ## CNS 11643 plane 1
543     $C->{option}->{designate_to}->{G94n}->{"\x48"} = 2; ## CNS 11643 plane 2
544     $C;
545     }
546     sub __2022_encode ($) {
547     my $C = shift->__2022__common;
548 wakaba 1.4 $C->{GR} = undef;
549 wakaba 1.1 $C->{C1} = $Encode::ISO2022::CHARSET{C1}->{"\x7E"}; ## empty set
550     $C->{G1} = $Encode::ISO2022::CHARSET{G96}->{"\x7E"}; ## empty set
551     $C;
552     }
553    
554     package Encode::ISO2022::SevenBit::CNExt;
555     use vars qw/@ISA/;
556     push @ISA, 'Encode::ISO2022::SevenBit::CN';
557     __PACKAGE__->Define (qw/iso-2022-cn-ext/);
558    
559     =item iso-2022-cn-ext
560    
561     An ISO/IEC 2022 based 7-bit encoding for Chinese,
562     defined by RFC 1922
563    
564     =cut
565    
566     sub __2022__common ($) {
567     my $C = shift->SUPER::__2022__common;
568     $C->{option}->{designate_to}->{G94n}->{"\x45"} = 1; ## ISO-IR 165
569     $C->{option}->{designate_to}->{G94n}->{"\x49"} = 3; ## CNS 11643 plane 3
570     $C->{option}->{designate_to}->{G94n}->{"\x4A"} = 3; ## CNS 11643 plane 4
571     $C->{option}->{designate_to}->{G94n}->{"\x4B"} = 3; ## CNS 11643 plane 5
572     $C->{option}->{designate_to}->{G94n}->{"\x4C"} = 3; ## CNS 11643 plane 6
573     $C->{option}->{designate_to}->{G94n}->{"\x4D"} = 3; ## CNS 11643 plane 7
574 wakaba 1.2 $C->{option}->{designate_to}->{G94n}->{P0_0} = 1; ## GB 12345
575     $C->{option}->{designate_to}->{G94n}->{P0_1} = 2; ## GB 7589
576     $C->{option}->{designate_to}->{G94n}->{P0_2} = 2; ## GB 13131
577     $C->{option}->{designate_to}->{G94n}->{P0_3} = 3; ## GB 7590
578     $C->{option}->{designate_to}->{G94n}->{P0_4} = 3; ## GB 13132
579     $C->{option}->{designate_to}->{G94n}->{P1_0} = 3; ## CNS 11643 plane 8
580     $C->{option}->{designate_to}->{G94n}->{P1_1} = 3; ## CNS 11643 plane 9
581     $C->{option}->{designate_to}->{G94n}->{P1_2} = 3; ## CNS 11643 plane 10
582     $C->{option}->{designate_to}->{G94n}->{P1_3} = 3; ## CNS 11643 plane 11
583     $C->{option}->{designate_to}->{G94n}->{P1_4} = 3; ## CNS 11643 plane 12
584     $C->{option}->{designate_to}->{G94n}->{P1_5} = 3; ## CNS 11643 plane 13
585     $C->{option}->{designate_to}->{G94n}->{P1_6} = 3; ## CNS 11643 plane 14
586     $C->{option}->{designate_to}->{G94n}->{P2_0} = 3; ## CNS 11643 plane 15
587     $C->{option}->{designate_to}->{G94n}->{P2_1} = 3; ## CNS 11643 plane 16
588 wakaba 1.1 $C;
589     }
590    
591     1;
592     __END__
593    
594     =back
595    
596 wakaba 1.9 =head1 AUTHORS
597    
598     Wakaba <w@suika.fam.cx>
599    
600     Nanashi-san
601    
602 wakaba 1.1 =head1 LICENSE
603    
604 wakaba 1.9 Copyright 2002 AUTHORS
605 wakaba 1.1
606     This library is free software; you can redistribute it
607     and/or modify it under the same terms as Perl itself.
608    
609     =cut
610    
611 wakaba 1.9 # $Date: 2002/10/04 23:58:04 $
612 wakaba 1.1 ### SevenBit.pm ends here

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24