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