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