1 |
wakaba |
1.1 |
=head1 NAME |
2 |
|
|
|
3 |
|
|
Encode::ISO2022::ISO646 --- Encode and decode of versions of |
4 |
|
|
ISO/IEC 646 |
5 |
|
|
|
6 |
|
|
=head1 ENCODINGS |
7 |
|
|
|
8 |
|
|
=over 4 |
9 |
|
|
|
10 |
|
|
=cut |
11 |
|
|
|
12 |
|
|
require 5.7.3; |
13 |
|
|
use strict; |
14 |
|
|
package Encode::ISO2022::ISO646; |
15 |
|
|
use vars qw($VERSION); |
16 |
|
|
$VERSION=do{my @r=(q$Revision: 1.3 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
17 |
|
|
use base qw(Encode::Encoding); |
18 |
|
|
require Encode::ISO2022; |
19 |
|
|
|
20 |
|
|
sub encode ($$;$) { |
21 |
|
|
my ($obj, $str, $chk) = @_; |
22 |
|
|
$_[1] = '' if $chk; |
23 |
|
|
$str = &Encode::ISO2022::internal_to_iso2022 ($str, $obj->__2022_encode); |
24 |
|
|
return $str; |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
sub decode ($$;$) { |
28 |
|
|
my ($obj, $str, $chk) = @_; |
29 |
|
|
$_[1] = '' if $chk; |
30 |
|
|
return &Encode::ISO2022::iso2022_to_internal ($str, $obj->__2022_decode); |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
sub __2022__common ($) { |
34 |
|
|
my $C = Encode::ISO2022->new_object; |
35 |
|
|
$C->{option}->{designate_to}->{C0}->{default} = -1; |
36 |
|
|
$C->{option}->{designate_to}->{C1}->{default} = -1; |
37 |
|
|
$C->{option}->{designate_to}->{G94}->{default} = -1; |
38 |
|
|
$C->{option}->{designate_to}->{G94}->{B} = -1; |
39 |
|
|
$C->{option}->{designate_to}->{G94n}->{default} = -1; |
40 |
|
|
$C->{option}->{designate_to}->{G96}->{default} = -1; |
41 |
|
|
$C->{option}->{designate_to}->{G96n}->{default} = -1; |
42 |
|
|
$C->{G1} = $Encode::ISO2022::CHARSET{G94}->{"\x7E"}; ## empty |
43 |
|
|
$C->{option}->{reset}->{Gdesignation} = 0; |
44 |
|
|
$C->{option}->{reset}->{Ginvoke} = 0; |
45 |
|
|
$C; |
46 |
|
|
} |
47 |
|
|
sub __2022_encode ($) { |
48 |
|
|
my $C = shift->__2022__common; |
49 |
|
|
$C->{GR} = undef; |
50 |
|
|
$C; |
51 |
|
|
} |
52 |
|
|
sub __2022_decode ($) { |
53 |
|
|
my $C = shift->__2022__common; |
54 |
|
|
$C; |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
package Encode::ISO2022::ISO646::ISO646basic1993; |
58 |
|
|
use vars qw/@ISA/; |
59 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
60 |
|
|
__PACKAGE__->Define (qw/ISO_646.basic:1983 ref csISO646basic1983/); |
61 |
|
|
|
62 |
|
|
=item ISO_646.basic:1983 |
63 |
|
|
|
64 |
|
|
A coded character set of |
65 |
|
|
basic code table of ISO/IEC 646 (only graphic characters, 02/00-07/14). |
66 |
|
|
(Name: ISO_646.basic:1983 (RFC 1345), ref (RFC 1345), csISO646basic1983 (IANA)) |
67 |
|
|
|
68 |
|
|
=cut |
69 |
|
|
|
70 |
|
|
sub __2022__common ($) { |
71 |
|
|
my $C = shift->SUPER::__2022__common; |
72 |
|
|
$C->{bit} = 7; |
73 |
|
|
$C->{C0} = $Encode::ISO2022::CHARSET{C0}->{"\x7E"}; ## empty |
74 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x21\x40"}; ## IR170 |
75 |
|
|
# 0x7E = undef |
76 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x21\x40"}]; |
77 |
|
|
$C; |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
package Encode::ISO2022::ISO646::INVARIANT; |
81 |
|
|
use vars qw/@ISA/; |
82 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
83 |
|
|
__PACKAGE__->Define (qw!INVARIANT csINVARIANT ISO/IEC646.BCT!); |
84 |
|
|
|
85 |
|
|
=item INVARIANT |
86 |
|
|
|
87 |
|
|
A coded character set of |
88 |
|
|
basic code table of ISO/IEC 646 (with C0 set of ISO/IEC 6429). |
89 |
|
|
(Name: INVARIANT (RFC 1345), csINVARIANT (IANA), ISO/IEC646.BCT) |
90 |
|
|
|
91 |
|
|
=cut |
92 |
|
|
|
93 |
|
|
sub __2022__common ($) { |
94 |
|
|
my $C = shift->SUPER::__2022__common; |
95 |
|
|
$C->{bit} = 7; |
96 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x21\x40"}; ## IR170 |
97 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x21\x40"}]; |
98 |
|
|
$C; |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
package Encode::ISO2022::ISO646::ISO646irv; |
102 |
|
|
use vars qw/@ISA/; |
103 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
104 |
|
|
__PACKAGE__->Define (qw!ISO_646.irv:1983 iso-ir-2 irv csISO2IntlRefVersion!); |
105 |
|
|
|
106 |
|
|
=item ISO_646.irv:1983 |
107 |
|
|
|
108 |
|
|
International reference version (IRV) of ISO 646:1983. |
109 |
|
|
(Name: ISO_646.irv:1983 (RFC 1345), iso-ir-2 (RFC 1345), irv (RFC 1345), |
110 |
|
|
csISO2IntlRefVersion (IANA)) |
111 |
|
|
|
112 |
|
|
=cut |
113 |
|
|
|
114 |
|
|
sub __2022__common ($) { |
115 |
|
|
my $C = shift->SUPER::__2022__common; |
116 |
|
|
$C->{bit} = 7; |
117 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x40"}; |
118 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
119 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x40"}]; |
120 |
|
|
$C; |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
package Encode::ISO2022::ISO646::BS_4730; |
124 |
|
|
use vars qw/@ISA/; |
125 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
126 |
|
|
__PACKAGE__->Define (qw!BS_4730 iso-ir-4 ISO646-GB gb uk csISO4UnitedKingdom!); |
127 |
|
|
|
128 |
|
|
=item BS_4730 |
129 |
|
|
|
130 |
|
|
BS 4730, a United Kingdom version of ISO/IEC 646. |
131 |
|
|
(Name: BS_4730 (RFC 1345), iso-ir-4 (RFC 1345), ISO646-GB (RFC 1345), |
132 |
|
|
gb (RFC 1345), uk (RFC 1345), csISO4UnitedKingdom (IANA)) |
133 |
|
|
|
134 |
|
|
=cut |
135 |
|
|
|
136 |
|
|
sub __2022__common ($) { |
137 |
|
|
my $C = shift->SUPER::__2022__common; |
138 |
|
|
$C->{bit} = 7; |
139 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x41"}; |
140 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
141 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x41"}]; |
142 |
|
|
$C; |
143 |
|
|
} |
144 |
|
|
|
145 |
|
|
package Encode::ISO2022::ISO646::USASCII; |
146 |
|
|
use vars qw/@ISA/; |
147 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
148 |
|
|
#__PACKAGE__->Define (qw!ANSI_X3.4-1968 iso-ir-6 ANSI_X3.4-1986 ISO_646.irv:1991 |
149 |
|
|
# ASCII ISO646-US US-ASCII us IBM367 cp367 csASCII!); |
150 |
|
|
|
151 |
|
|
=item ANSI_X3.4-1968 |
152 |
|
|
|
153 |
|
|
ANSI X3.4-1968 or ISO/IEC 646:1991 International reference version (IRV). |
154 |
|
|
(Name: ANSI_X3.4-1968 (RFC 1345), iso-ir-6 (RFC 1345), ANSI_X3.4-1986 (RFC 1345), |
155 |
|
|
ISO_646.irv:1991 (RFC 1345), ASCII (RFC 1345), ISO646-US (RFC 1345), |
156 |
|
|
US-ASCII (RFC 1345), us (RFC 1345), IBM367 (RFC 1345), cp367 (RFC 1345), |
157 |
|
|
csASCII (IANA)) |
158 |
|
|
|
159 |
|
|
Note that this coding system defined in this module is not used, |
160 |
|
|
since perl standard Encode module already implement this. |
161 |
|
|
|
162 |
|
|
=cut |
163 |
|
|
|
164 |
|
|
sub __2022__common ($) { |
165 |
|
|
my $C = shift->SUPER::__2022__common; |
166 |
|
|
$C->{bit} = 7; |
167 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x41"}; |
168 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
169 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x41"}]; |
170 |
|
|
$C; |
171 |
|
|
} |
172 |
|
|
|
173 |
|
|
package Encode::ISO2022::ISO646::SEN_850200_B; |
174 |
|
|
use vars qw/@ISA/; |
175 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
176 |
|
|
__PACKAGE__->Define (qw!SEN_850200_B iso-ir-10 FI ISO646-FI ISO646-SE |
177 |
|
|
csISO10Swedish!); |
178 |
|
|
|
179 |
|
|
=item SEN_850200_B |
180 |
|
|
|
181 |
|
|
SEN 850200 Appendix B, Swedish version of ISO/IEC 646. |
182 |
|
|
(Name: SEN_850200_B (RFC 1345), iso-ir-10 (RFC 1345), FI (RFC 1345), |
183 |
|
|
ISO646-FI (RFC 1345), ISO646-SE (RFC 1345), se (RFC 1345), csISO10Swedish (IANA)) |
184 |
|
|
|
185 |
|
|
=cut |
186 |
|
|
|
187 |
|
|
sub __2022__common ($) { |
188 |
|
|
my $C = shift->SUPER::__2022__common; |
189 |
|
|
$C->{bit} = 7; |
190 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x47"}; |
191 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
192 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x47"}]; |
193 |
|
|
$C; |
194 |
|
|
} |
195 |
|
|
|
196 |
|
|
package Encode::ISO2022::ISO646::SEN_850200_C; |
197 |
|
|
use vars qw/@ISA/; |
198 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
199 |
|
|
__PACKAGE__->Define (qw!SEN_850200_C iso-ir-11 ISO646-SE2 |
200 |
|
|
csISO11SwedishForNames!); |
201 |
|
|
|
202 |
|
|
=item SEN_850200_C |
203 |
|
|
|
204 |
|
|
SEN 850200 Appendix C, Swedish version of ISO/IEC 646 for names. |
205 |
|
|
(Name: SEN_850200_C (RFC 1345), iso-ir-11 (RFC 1345), ISO646-SE2 (RFC 1345), |
206 |
|
|
csISO11SwedishForNames (IANA)) |
207 |
|
|
|
208 |
|
|
=cut |
209 |
|
|
|
210 |
|
|
sub __2022__common ($) { |
211 |
|
|
my $C = shift->SUPER::__2022__common; |
212 |
|
|
$C->{bit} = 7; |
213 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x48"}; |
214 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
215 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x48"}]; |
216 |
|
|
$C; |
217 |
|
|
} |
218 |
|
|
|
219 |
|
|
package Encode::ISO2022::ISO646::IT; |
220 |
|
|
use vars qw/@ISA/; |
221 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
222 |
|
|
__PACKAGE__->Define (qw!IT iso-ir-15 ISO646-IT csISO15Italian!); |
223 |
|
|
|
224 |
|
|
=item IT |
225 |
|
|
|
226 |
|
|
Italic version of ISO/IEC 646. |
227 |
|
|
(Name: IT (RFC 1345), iso-ir-15 (RFC 1345), ISO646-IT (RFC 1345), |
228 |
|
|
csISO15Italian (IANA)) |
229 |
|
|
|
230 |
|
|
=cut |
231 |
|
|
|
232 |
|
|
sub __2022__common ($) { |
233 |
|
|
my $C = shift->SUPER::__2022__common; |
234 |
|
|
$C->{bit} = 7; |
235 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x59"}; |
236 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
237 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x59"}]; |
238 |
|
|
$C; |
239 |
|
|
} |
240 |
|
|
|
241 |
|
|
package Encode::ISO2022::ISO646::PT; |
242 |
|
|
use vars qw/@ISA/; |
243 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
244 |
|
|
__PACKAGE__->Define (qw!PT iso-ir-16 ISO646-PT csISO16Portuguese!); |
245 |
|
|
|
246 |
|
|
=item PT |
247 |
|
|
|
248 |
|
|
Portuguese version of ISO/IEC 646. |
249 |
|
|
(Name: PT (RFC 1345), iso-ir-16 (RFC 1345), ISO646-PT (RFC 1345), |
250 |
|
|
csISO16Portuguese (IANA)) |
251 |
|
|
|
252 |
|
|
=cut |
253 |
|
|
|
254 |
|
|
sub __2022__common ($) { |
255 |
|
|
my $C = shift->SUPER::__2022__common; |
256 |
|
|
$C->{bit} = 7; |
257 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x4C"}; |
258 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
259 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x4C"}]; |
260 |
|
|
$C; |
261 |
|
|
} |
262 |
|
|
|
263 |
|
|
package Encode::ISO2022::ISO646::ES; |
264 |
|
|
use vars qw/@ISA/; |
265 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
266 |
|
|
__PACKAGE__->Define (qw!ES iso-ir-17 ISO646-ES csISO17Spanish!); |
267 |
|
|
|
268 |
|
|
=item ES |
269 |
|
|
|
270 |
|
|
Spanish version of ISO/IEC 646. |
271 |
|
|
(Name: ES (RFC 1345), iso-ir-17 (RFC 1345), ISO646-ES (RFC 1345), |
272 |
|
|
csISO17Spanish (IANA)) |
273 |
|
|
|
274 |
|
|
=cut |
275 |
|
|
|
276 |
|
|
sub __2022__common ($) { |
277 |
|
|
my $C = shift->SUPER::__2022__common; |
278 |
|
|
$C->{bit} = 7; |
279 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x5A"}; |
280 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
281 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x5A"}]; |
282 |
|
|
$C; |
283 |
|
|
} |
284 |
|
|
|
285 |
|
|
package Encode::ISO2022::ISO646::DIN_66003; |
286 |
|
|
use vars qw/@ISA/; |
287 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
288 |
|
|
__PACKAGE__->Define (qw!DIN_66003 iso-ir-21 de ISO646-de csISO21German!); |
289 |
|
|
|
290 |
|
|
=item DIN_66003 |
291 |
|
|
|
292 |
|
|
DIN 66003, German version of ISO/IEC 646. |
293 |
|
|
(Name: DIN_66003 (RFC 1345), iso-ir-21 (RFC 1345), de (RFC 1345), |
294 |
|
|
ISO646-de (RFC 1345), csISO21German (IANA)) |
295 |
|
|
|
296 |
|
|
=cut |
297 |
|
|
|
298 |
|
|
sub __2022__common ($) { |
299 |
|
|
my $C = shift->SUPER::__2022__common; |
300 |
|
|
$C->{bit} = 7; |
301 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x4B"}; |
302 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
303 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x4B"}]; |
304 |
|
|
$C; |
305 |
|
|
} |
306 |
|
|
|
307 |
|
|
package Encode::ISO2022::ISO646::DIN_66003; |
308 |
|
|
use vars qw/@ISA/; |
309 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
310 |
|
|
__PACKAGE__->Define (qw!NF_Z_62-010_(1973) iso-ir-25 ISO646-FR1 csISO25French!); |
311 |
|
|
|
312 |
|
|
=item NF_Z_62-010_(1973) |
313 |
|
|
|
314 |
|
|
NF Z 62-010 1973, French version of ISO/IEC 646. |
315 |
|
|
(Name: NF_Z_62-010_(1973) (RFC 1345), iso-ir-25 (RFC 1345), |
316 |
|
|
ISO646-FR1 (RFC 1345), csISO25French (IANA)) |
317 |
|
|
|
318 |
|
|
=cut |
319 |
|
|
|
320 |
|
|
sub __2022__common ($) { |
321 |
|
|
my $C = shift->SUPER::__2022__common; |
322 |
|
|
$C->{bit} = 7; |
323 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x52"}; |
324 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
325 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x52"}]; |
326 |
|
|
$C; |
327 |
|
|
} |
328 |
|
|
|
329 |
|
|
package Encode::ISO2022::ISO646::GB_1988; |
330 |
|
|
use vars qw/@ISA/; |
331 |
|
|
push @ISA, 'Encode::ISO2022::ISO646'; |
332 |
|
|
__PACKAGE__->Define (qw!GB_1988-80 iso-ir-57 cn ISO646-cn csISO57GB1988!); |
333 |
|
|
|
334 |
|
|
=item GB_1988-80 |
335 |
|
|
|
336 |
|
|
GB_1988-80, Chinese version of ISO/IEC 646. |
337 |
|
|
(Name: GB_1988-80 (RFC 1345), iso-ir-57 (RFC 1345), cn (RFC 1345), |
338 |
|
|
ISO646-cn (RFC 1345), csISO57GB1988 (IANA)) |
339 |
|
|
|
340 |
|
|
=cut |
341 |
|
|
|
342 |
|
|
sub __2022__common ($) { |
343 |
|
|
my $C = shift->SUPER::__2022__common; |
344 |
|
|
$C->{bit} = 7; |
345 |
|
|
$C->{G0} = $Encode::ISO2022::CHARSET{G94}->{"\x54"}; |
346 |
|
|
$C->{G1} = $C->{G0}; $C->{G2} = $C->{G1}; $C->{G3} = $C->{G1}; |
347 |
|
|
$C->{option}->{undef_char} = ["\x3F", {type => 'G94', charset => "\x54"}]; |
348 |
|
|
$C; |
349 |
|
|
} |
350 |
|
|
|
351 |
|
|
|
352 |
|
|
1; |
353 |
|
|
__END__ |
354 |
|
|
|
355 |
|
|
=back |
356 |
|
|
|
357 |
|
|
Note that although other JISes such as JIS X 0212 and JIS X 9010 |
358 |
|
|
define ISO/IEC 2022-comfprming coded character sets, |
359 |
|
|
these standards do not define complete coding system (but define |
360 |
|
|
as used on ISO/IEC 2022 environment), so this module |
361 |
|
|
does not include those coded character sets. (IETF RFC 1345 |
362 |
|
|
and IANAREG give charset name to coded character sets |
363 |
|
|
consist of such standards. But those are defined by RFC 1345, |
364 |
|
|
not by JIS. Such coded character sets should be implemented |
365 |
|
|
in Encode::ISO2022::RFC1345.) |
366 |
|
|
|
367 |
|
|
=head1 LICENSE |
368 |
|
|
|
369 |
|
|
Copyright 2002 Wakaba <w@suika.fam.cx> |
370 |
|
|
|
371 |
|
|
This library is free software; you can redistribute it |
372 |
|
|
and/or modify it under the same terms as Perl itself. |
373 |
|
|
|
374 |
|
|
=cut |
375 |
|
|
|
376 |
|
|
# $Date: 2002/09/20 14:01:45 $ |
377 |
|
|
### JIS.pm ends here |