/[suikacvs]/markup/html/whatpm/Whatpm/Charset/DecodeHandle.pm
Suika

Contents of /markup/html/whatpm/Whatpm/Charset/DecodeHandle.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (hide annotations) (download)
Sun Sep 14 07:19:47 2008 UTC (16 years, 10 months ago) by wakaba
Branch: MAIN
Changes since 1.15: +18 -100 lines
++ whatpm/Whatpm/ChangeLog	14 Sep 2008 07:19:17 -0000
	* HTML.pm.src: Make a "bare ero" error for unknown
	entities point the "&" character.

2008-09-14  Wakaba  <wakaba@suika.fam.cx>

++ whatpm/Whatpm/Charset/ChangeLog	14 Sep 2008 07:19:40 -0000
	* DecodeHandle.pm: Merge the ShiftJIS class into the Encode class.

2008-09-14  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 package Whatpm::Charset::DecodeHandle;
2     use strict;
3    
4 wakaba 1.9 ## NOTE: |Message::Charset::Info| uses this module without calling
5     ## the constructor.
6 wakaba 1.15 use Message::Charset::Info;
7 wakaba 1.9
8 wakaba 1.1 my $XML_AUTO_CHARSET = q<http://suika.fam.cx/www/2006/03/xml-entity/>;
9     my $IANA_CHARSET = q<urn:x-suika-fam-cx:charset:>;
10     my $PERL_CHARSET = q<http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.>;
11     my $XML_CHARSET = q<http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.>;
12    
13     ## ->create_decode_handle ($charset_uri, $byte_stream, $onerror)
14     sub create_decode_handle ($$$;$) {
15     my $csdef = $Whatpm::Charset::CharsetDef->{$_[1]};
16     my $obj = {
17 wakaba 1.15 category => 0,
18 wakaba 1.9 char_buffer => \(my $s = ''),
19 wakaba 1.11 char_buffer_pos => 0,
20 wakaba 1.1 character_queue => [],
21     filehandle => $_[2],
22     charset => $_[1],
23     byte_buffer => '',
24     onerror => $_[3] || sub {},
25     };
26     if ($csdef->{uri}->{$XML_AUTO_CHARSET} or
27     $obj->{charset} eq $XML_AUTO_CHARSET) {
28     my $b = ''; # UTF-8 w/o BOM
29     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
30 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
31 wakaba 1.1 if (read $obj->{filehandle}, $b, 256) {
32     no warnings "substr";
33     no warnings "uninitialized";
34     if (substr ($b, 0, 1) eq "<") {
35     if (substr ($b, 1, 1) eq "?") { # ASCII8
36     if ($b =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
37     encoding\s*=\s*["']([^"']*)/x) {
38 wakaba 1.2 $obj->{input_encoding} = $1;
39 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
40     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
41     if (not $csdef->{ascii8} or $csdef->{bom_required}) {
42     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
43     charset_uri => $uri,
44     charset_name => $obj->{input_encoding});
45     }
46     } else {
47     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
48 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
49 wakaba 1.1 }
50     if (defined $csdef->{no_bom_variant}) {
51     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant}};
52     }
53     } elsif (substr ($b, 1, 1) eq "\x00") {
54     if (substr ($b, 2, 2) eq "?\x00") { # ASCII16LE
55     my $c = $b; $c =~ tr/\x00//d;
56     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
57     encoding\s*=\s*["']([^"']*)/x) {
58 wakaba 1.2 $obj->{input_encoding} = $1;
59 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
60     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
61     if (not $csdef->{ascii16} or $csdef->{ascii16be} or
62     $csdef->{bom_required}) {
63     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
64     charset_uri => $uri,
65     charset_name => $obj->{input_encoding});
66     }
67     } else {
68     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
69 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
70 wakaba 1.1 }
71     if (defined $csdef->{no_bom_variant16le}) {
72     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant16le}};
73     }
74     } elsif (substr ($b, 2, 2) eq "\x00\x00") { # ASCII32Endian4321
75     my $c = $b; $c =~ tr/\x00//d;
76     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
77     encoding\s*=\s*["']([^"']*)/x) {
78 wakaba 1.2 $obj->{input_encoding} = $1;
79 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
80     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
81     if (not $csdef->{ascii32} or
82     $csdef->{ascii32endian1234} or
83     $csdef->{ascii32endian2143} or
84     $csdef->{ascii32endian3412} or
85     $csdef->{bom_required}) {
86     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
87     charset_uri => $uri,
88     charset_name => $obj->{input_encoding});
89     }
90     } else {
91     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
92 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
93 wakaba 1.1 }
94     if (defined $csdef->{no_bom_variant32endian4321}) {
95     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant32endian4321}};
96     }
97     }
98     }
99     } elsif (substr ($b, 0, 3) eq "\xEF\xBB\xBF") { # UTF8
100     $obj->{has_bom} = 1;
101     substr ($b, 0, 3) = '';
102     my $c = $b;
103     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
104     encoding\s*=\s*["']([^"']*)/x) {
105 wakaba 1.2 $obj->{input_encoding} = $1;
106 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
107     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
108     if (not $csdef->{utf8_encoding_scheme} or
109     not $csdef->{bom_allowed}) {
110     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
111     charset_uri => $uri,
112     charset_name => $obj->{input_encoding});
113     }
114     } else {
115     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
116 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
117 wakaba 1.1 }
118     if (defined $csdef->{no_bom_variant}) {
119     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant}};
120     }
121     } elsif (substr ($b, 0, 2) eq "\x00<") {
122     if (substr ($b, 2, 2) eq "\x00?") { # ASCII16BE
123     my $c = $b; $c =~ tr/\x00//d;
124     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
125     encoding\s*=\s*["']([^"']*)/x) {
126 wakaba 1.2 $obj->{input_encoding} = $1;
127 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
128     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
129     if (not $csdef->{ascii16} or $csdef->{ascii16le} or
130     $csdef->{bom_required}) {
131     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
132     charset_uri => $uri,
133     charset_name => $obj->{input_encoding});
134     }
135     } else {
136     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
137 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
138 wakaba 1.1 }
139     if (defined $csdef->{no_bom_variant16be}) {
140     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant16be}};
141     }
142     } elsif (substr ($b, 2, 2) eq "\x00\x00") { # ASCII32Endian3412
143     my $c = $b; $c =~ tr/\x00//d;
144     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
145     encoding\s*=\s*["']([^"']*)/x) {
146 wakaba 1.2 $obj->{input_encoding} = $1;
147 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
148     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
149     if (not $csdef->{ascii32} or
150     $csdef->{ascii32endian1234} or
151     $csdef->{ascii32endian2143} or
152     $csdef->{ascii32endian4321} or
153     $csdef->{bom_required}) {
154     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
155     charset_uri => $uri,
156     charset_name => $obj->{input_encoding});
157     }
158     } else {
159     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
160 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
161 wakaba 1.1 }
162     if (defined $csdef->{no_bom_variant32endian3412}) {
163     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant32endian3412}};
164     }
165     }
166     } elsif (substr ($b, 0, 2) eq "\xFE\xFF") {
167     if (substr ($b, 2, 2) eq "\x00<") { # ASCII16BE
168     $obj->{has_bom} = 1;
169     substr ($b, 0, 2) = '';
170     my $c = $b; $c =~ tr/\x00//d;
171     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
172     encoding\s*=\s*["']([^"']*)/x) {
173 wakaba 1.2 $obj->{input_encoding} = $1;
174 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
175     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
176     if (not $csdef->{ascii16} or
177     $csdef->{ascii16le} or
178     not $csdef->{bom_allowed}) {
179     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
180     charset_uri => $uri,
181     charset_name => $obj->{input_encoding});
182     }
183     } else {
184     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-16be'};
185 wakaba 1.2 $obj->{input_encoding} = 'UTF-16';
186 wakaba 1.1 }
187     if (defined $csdef->{no_bom_variant16be}) {
188     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant16be}};
189     }
190     } elsif (substr ($b, 2, 2) eq "\x00\x00") { # ASCII32Endian3412
191     $obj->{has_bom} = 1;
192     substr ($b, 0, 4) = '';
193     my $c = $b; $c =~ tr/\x00//d;
194     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
195     encoding\s*=\s*["']([^"']*)/x) {
196 wakaba 1.2 $obj->{input_encoding} = $1;
197 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
198     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
199     if (not $csdef->{ascii32} or
200     $csdef->{ascii32endian1234} or
201     $csdef->{ascii32endian2143} or
202     $csdef->{ascii32endian4321} or
203     not $csdef->{bom_allowed}) {
204     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
205     charset_uri => $uri,
206     charset_name => $obj->{input_encoding});
207     }
208     } else {
209     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-16be'};
210 wakaba 1.2 $obj->{input_encoding} = 'UTF-16';
211 wakaba 1.1 $obj->{byte_buffer} .= "\x00\x00";
212     }
213     if (defined $csdef->{no_bom_variant32endian3412}) {
214     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant32endian3412}};
215     }
216     } else {
217     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-16be'};
218 wakaba 1.2 $obj->{input_encoding} = 'UTF-16';
219 wakaba 1.1 substr ($b, 0, 2) = '';
220     $obj->{has_bom} = 1;
221     }
222     } elsif (substr ($b, 0, 2) eq "\xFF\xFE") {
223     if (substr ($b, 2, 2) eq "<\x00") { # ASCII16LE
224     $obj->{has_bom} = 1;
225     substr ($b, 0, 2) = '';
226     my $c = $b; $c =~ tr/\x00//d;
227     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
228     encoding\s*=\s*["']([^"']*)/x) {
229 wakaba 1.2 $obj->{input_encoding} = $1;
230 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
231     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
232     if (not $csdef->{ascii16} or
233     $csdef->{ascii16be} or
234     not $csdef->{bom_allowed}) {
235     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
236     charset_uri => $uri,
237     charset_name => $obj->{input_encoding});
238     }
239     } else {
240     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-16le'};
241 wakaba 1.2 $obj->{input_encoding} = 'UTF-16';
242 wakaba 1.1 }
243     if (defined $csdef->{no_bom_variant16le}) {
244     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant16le}};
245     }
246     } elsif (substr ($b, 2, 2) eq "\x00\x00") { # ASCII32Endian4321
247     $obj->{has_bom} = 1;
248     substr ($b, 0, 4) = '';
249     my $c = $b; $c =~ tr/\x00//d;
250     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
251     encoding\s*=\s*["']([^"']*)/x) {
252 wakaba 1.2 $obj->{input_encoding} = $1;
253 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
254     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
255     if (not $csdef->{ascii32} or
256     $csdef->{ascii32endian1234} or
257     $csdef->{ascii32endian2143} or
258     $csdef->{ascii32endian3412} or
259     not $csdef->{bom_allowed}) {
260     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
261     charset_uri => $uri,
262     charset_name => $obj->{input_encoding});
263     }
264     } else {
265     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-16le'};
266 wakaba 1.2 $obj->{input_encoding} = 'UTF-16';
267 wakaba 1.1 $obj->{byte_buffer} .= "\x00\x00";
268     }
269     if (defined $csdef->{no_bom_variant32endian4321}) {
270     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant32endian4321}};
271     }
272     } else {
273     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-16le'};
274 wakaba 1.2 $obj->{input_encoding} = 'UTF-16';
275 wakaba 1.1 substr ($b, 0, 2) = '';
276     $obj->{has_bom} = 1;
277     }
278     } elsif (substr ($b, 0, 2) eq "\x00\x00") {
279     if (substr ($b, 2, 2) eq "\x00<") { # ASCII32Endian1234
280     my $c = $b; $c =~ tr/\x00//d;
281     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
282     encoding\s*=\s*["']([^"']*)/x) {
283 wakaba 1.2 $obj->{input_encoding} = $1;
284 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
285     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
286     if (not $csdef->{ascii32} or
287     $csdef->{ascii32endian2143} or
288     $csdef->{ascii32endian3412} or
289     $csdef->{ascii32endian4321} or
290     $csdef->{bom_required}) {
291     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
292     charset_uri => $uri,
293     charset_name => $obj->{input_encoding});
294     }
295     } else {
296     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
297 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
298 wakaba 1.1 }
299     if (defined $csdef->{no_bom_variant32endian1234}) {
300     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant32endian1234}};
301     }
302     } elsif (substr ($b, 2, 2) eq "<\x00") { # ASCII32Endian2143
303     my $c = $b; $c =~ tr/\x00//d;
304     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
305     encoding\s*=\s*["']([^"']*)/x) {
306 wakaba 1.2 $obj->{input_encoding} = $1;
307 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
308     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
309     if (not $csdef->{ascii32} or
310     $csdef->{ascii32endian1234} or
311     $csdef->{ascii32endian3412} or
312     $csdef->{ascii32endian4321} or
313     $csdef->{bom_required}) {
314     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
315     charset_uri => $uri,
316     charset_name => $obj->{input_encoding});
317     }
318     } else {
319     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
320 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
321 wakaba 1.1 }
322     if (defined $csdef->{no_bom_variant32endian2143}) {
323     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant32endian2143}};
324     }
325     } elsif (substr ($b, 2, 2) eq "\xFE\xFF") { # ASCII32Endian1234
326     $obj->{has_bom} = 1;
327     substr ($b, 0, 4) = '';
328     my $c = $b; $c =~ tr/\x00//d;
329     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
330     encoding\s*=\s*["']([^"']*)/x) {
331 wakaba 1.2 $obj->{input_encoding} = $1;
332 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
333     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
334     if (not $csdef->{ascii32} or
335     $csdef->{ascii32endian2143} or
336     $csdef->{ascii32endian3412} or
337     $csdef->{ascii32endian4321} or
338     $csdef->{bom_required}) {
339     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
340     charset_uri => $uri,
341     charset_name => $obj->{input_encoding});
342     }
343     } else {
344     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
345 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
346 wakaba 1.1 $obj->{has_bom} = 0;
347     $obj->{byte_buffer} .= "\x00\x00\xFE\xFF";
348     }
349     if (defined $csdef->{no_bom_variant32endian1234}) {
350     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant32endian1234}};
351     }
352     } elsif (substr ($b, 2, 2) eq "\xFF\xFE") { # ASCII32Endian2143
353     $obj->{has_bom} = 1;
354     substr ($b, 0, 4) = '';
355     my $c = $b; $c =~ tr/\x00//d;
356     if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)?
357     encoding\s*=\s*["']([^"']*)/x) {
358 wakaba 1.2 $obj->{input_encoding} = $1;
359 wakaba 1.1 my $uri = name_to_uri (undef, 'xml', $obj->{input_encoding});
360     $csdef = $Whatpm::Charset::CharsetDef->{$uri};
361     if (not $csdef->{ascii32} or
362     $csdef->{ascii32endian1234} or
363     $csdef->{ascii32endian3412} or
364     $csdef->{ascii32endian4321} or
365     $csdef->{bom_required}) {
366     $obj->{onerror}->(undef, 'charset-name-mismatch-error',
367     charset_uri => $uri,
368     charset_name => $obj->{input_encoding});
369     }
370     } else {
371     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'};
372 wakaba 1.2 $obj->{input_encoding} = 'UTF-8';
373 wakaba 1.1 $obj->{has_bom} = 0;
374     $obj->{byte_buffer} .= "\x00\x00\xFF\xFE";
375     }
376     if (defined $csdef->{no_bom_variant32endian2143}) {
377     $csdef = $Whatpm::Charset::CharsetDef->{$csdef->{no_bom_variant32endian2143}};
378     }
379     }
380     # \x4C\x6F\xA7\x94 EBCDIC
381     } # buffer
382     $obj->{byte_buffer} .= $b;
383     } # read
384     } elsif ($csdef->{uri}->{$XML_CHARSET.'utf-8'}) {
385     ## BOM is optional.
386     my $b = '';
387     if (read $obj->{filehandle}, $b, 3) {
388     if ($b eq "\xEF\xBB\xBF") {
389     $obj->{has_bom} = 1;
390     } else {
391     $obj->{byte_buffer} .= $b;
392     }
393     }
394     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-8'}; # UTF-8 w/o BOM
395     } elsif ($csdef->{uri}->{$XML_CHARSET.'utf-16'}) {
396     ## BOM is mandated.
397     my $b = '';
398     if (read $obj->{filehandle}, $b, 2) {
399     if ($b eq "\xFE\xFF") {
400     $obj->{has_bom} = 1; # UTF-16BE w/o BOM
401     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-16be'};
402     } elsif ($b eq "\xFF\xFE") {
403     $obj->{has_bom} = 1; # UTF-16LE w/o BOM
404     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-16le'};
405     } else {
406     $obj->{onerror}->(undef, 'no-bom-error', charset_uri => $obj->{charset});
407     $obj->{has_bom} = 0;
408     $obj->{byte_buffer} .= $b; # UTF-16BE w/o BOM
409     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-16be'};
410     }
411     } else {
412     $obj->{onerror}->(undef, 'no-bom-error', charset_uri => $obj->{charset});
413     $obj->{has_bom} = 0; # UTF-16BE w/o BOM
414     $csdef = $Whatpm::Charset::CharsetDef->{$PERL_CHARSET.'utf-16be'};
415     }
416     }
417    
418     if ($csdef->{uri}->{$XML_CHARSET.'iso-2022-jp'}) {
419     $obj->{state_2440} = 'gl-jis-1997-swapped';
420     $obj->{state_2442} = 'gl-jis-1997';
421     $obj->{state} = 'state_2842';
422     require Encode::GLJIS1997Swapped;
423     require Encode::GLJIS1997;
424     if (Encode::find_encoding ($obj->{state_2440}) and
425     Encode::find_encoding ($obj->{state_2442})) {
426     return bless $obj, 'Whatpm::Charset::DecodeHandle::ISO2022JP';
427     }
428     } elsif ($csdef->{uri}->{$IANA_CHARSET.'iso-2022-jp'}) {
429     $obj->{state_2440} = 'gl-jis-1978';
430     $obj->{state_2442} = 'gl-jis-1983';
431     $obj->{state} = 'state_2842';
432     require Encode::GLJIS1978;
433     require Encode::GLJIS1983;
434     if (Encode::find_encoding ($obj->{state_2440}) and
435     Encode::find_encoding ($obj->{state_2442})) {
436     return bless $obj, 'Whatpm::Charset::DecodeHandle::ISO2022JP';
437     }
438     } elsif (defined $csdef->{perl_name}->[0]) {
439     if ($csdef->{uri}->{$XML_CHARSET.'euc-jp'} or
440     $csdef->{uri}->{$IANA_CHARSET.'euc-jp'}) {
441     $obj->{perl_encoding_name} = $csdef->{perl_name}->[0];
442     require Encode::EUCJP1997;
443     if (Encode::find_encoding ($obj->{perl_encoding_name})) {
444 wakaba 1.15 $obj->{category} |= Message::Charset::Info::CHARSET_CATEGORY_EUCJP;
445     return bless $obj, 'Whatpm::Charset::DecodeHandle::Encode';
446 wakaba 1.1 }
447     } elsif ($csdef->{uri}->{$XML_CHARSET.'shift_jis'} or
448     $csdef->{uri}->{$IANA_CHARSET.'shift_jis'}) {
449     $obj->{perl_encoding_name} = $csdef->{perl_name}->[0];
450     require Encode::ShiftJIS1997;
451     if (Encode::find_encoding ($obj->{perl_encoding_name})) {
452 wakaba 1.16 return bless $obj, 'Whatpm::Charset::DecodeHandle::Encode';
453 wakaba 1.1 }
454     } elsif ($csdef->{is_block_safe}) {
455     $obj->{perl_encoding_name} = $csdef->{perl_name}->[0];
456     require Encode;
457     if (Encode::find_encoding ($obj->{perl_encoding_name})) {
458     return bless $obj, 'Whatpm::Charset::DecodeHandle::Encode';
459     }
460     }
461     }
462    
463     $obj->{onerror}->(undef, 'charset-not-supported-error',
464     charset_uri => $obj->{charset});
465     return undef;
466     } # create_decode_handle
467    
468     sub name_to_uri ($$$) {
469     my $domain = $_[1];
470     my $name = lc $_[2];
471    
472     if ($domain eq 'ietf') {
473     return $IANA_CHARSET . $name;
474     } elsif ($domain eq 'xml') {
475     if ({
476     'utf-8' => 1,
477     'utf-16' => 1,
478     'iso-10646-ucs-2' => 1,
479     'iso-10646-ucs-4' => 1,
480     'iso-8859-1' => 1,
481     'iso-8859-2' => 1,
482     'iso-8859-3' => 1,
483     'iso-8859-4' => 1,
484     'iso-8859-5' => 1,
485     'iso-8859-6' => 1,
486     'iso-8859-7' => 1,
487     'iso-8859-8' => 1,
488     'iso-8859-9' => 1,
489     'iso-8859-10' => 1,
490     'iso-8859-11' => 1,
491     'iso-8859-13' => 1,
492     'iso-8859-14' => 1,
493     'iso-8859-15' => 1,
494     'iso-8859-16' => 1,
495     'iso-2022-jp' => 1,
496     'shift_jis' => 1,
497     'euc-jp' => 1,
498     }->{$name}) {
499     return $XML_CHARSET . $name;
500     }
501    
502     my $uri = $IANA_CHARSET . $name;
503     return $uri if $Whatpm::Charset::CharsetDef->{$uri};
504    
505     return $XML_CHARSET . $name;
506     } else {
507     return undef;
508     }
509     } # name_to_uri
510    
511     sub uri_to_name ($$$) {
512     my (undef, $domain, $uri) = @_;
513 wakaba 1.2
514     if ($domain eq 'xml') {
515     my $v = $Whatpm::Charset::CharsetDef->{$uri}->{xml_name};
516     return $v if defined $v;
517    
518     if (substr ($uri, 0, length $XML_CHARSET) eq $XML_CHARSET) {
519     return substr ($uri, length $XML_CHARSET);
520     }
521    
522     $domain = 'ietf'; ## TODO: XML encoding name has smaller range
523     }
524    
525     if ($domain eq 'ietf') {
526     my $v = $Whatpm::Charset::CharsetDef->{$uri}->{iana_name};
527     return $v->[0] if defined $v;
528    
529     if (substr ($uri, 0, length $IANA_CHARSET) eq $IANA_CHARSET) {
530 wakaba 1.1 return substr ($uri, length $IANA_CHARSET);
531     }
532     }
533    
534     return undef;
535     } # uri_to_name
536    
537 wakaba 1.3 require IO::Handle;
538    
539     package Whatpm::Charset::DecodeHandle::ByteBuffer;
540    
541 wakaba 1.7 ## NOTE: Provides a byte buffer wrapper object.
542    
543 wakaba 1.3 sub new ($$) {
544     my $self = bless {
545     buffer => '',
546     }, shift;
547     $self->{filehandle} = shift;
548     return $self;
549     } # new
550    
551     sub read {
552     my $self = shift;
553     my $pos = length $self->{buffer};
554     my $r = $self->{filehandle}->read ($self->{buffer}, $_[1], $pos);
555     substr ($_[0], $_[2]) = substr ($self->{buffer}, $pos);
556 wakaba 1.8 ## NOTE: This would do different behavior from Perl's standard
557     ## |read| when $pos points beyond the end of the string.
558 wakaba 1.3 return $r;
559     } # read
560    
561     sub close { $_[0]->{filehandle}->close }
562    
563 wakaba 1.11 package Whatpm::Charset::DecodeHandle::CharString;
564    
565     ## NOTE: Same as Perl's standard |open $handle, '<', \$char_string|,
566     ## but supports |ungetc| and other extensions.
567    
568     sub new ($$) {
569     my $self = bless {pos => 0}, shift;
570     $self->{string} = shift; # must be a scalar ref
571     return $self;
572     } # new
573    
574     sub getc ($) {
575     my $self = shift;
576     if ($self->{pos} < length ${$self->{string}}) {
577     return substr ${$self->{string}}, $self->{pos}++, 1;
578     } else {
579     return undef;
580     }
581     } # getc
582    
583     sub read ($$$$) {
584     #my ($self, $scalar, $length, $offset) = @_;
585     my $self = $_[0];
586     my $length = $_[2] || 0;
587     my $offset = $_[3];
588     ## NOTE: We don't support standard Perl semantics if $offset is
589     ## greater than the length of $scalar.
590     substr ($_[1], $offset) = substr (${$self->{string}}, $self->{pos}, $length);
591     my $count = (length $_[1]) - $offset;
592     $self->{pos} += $count;
593     return $count;
594     } # read
595    
596 wakaba 1.12 sub manakai_read_until ($$$;$) {
597     #my ($self, $scalar, $pattern, $offset) = @_;
598     my $self = $_[0];
599 wakaba 1.11 pos (${$self->{string}}) = $self->{pos};
600 wakaba 1.12 if (${$self->{string}} =~ /\G(?>$_[2])+/) {
601     substr ($_[1], $_[3]) = substr (${$self->{string}}, $-[0], $+[0] - $-[0]);
602 wakaba 1.11 $self->{pos} += $+[0] - $-[0];
603 wakaba 1.12 return $+[0] - $-[0];
604 wakaba 1.11 } else {
605 wakaba 1.12 return 0;
606 wakaba 1.11 }
607 wakaba 1.12 } # manakai_read_until
608 wakaba 1.11
609     sub ungetc ($$) {
610     my $self = shift;
611     ## Ignore second parameter.
612     $self->{pos}-- if $self->{pos} > 0;
613     } # ungetc
614    
615     sub close ($) { }
616    
617 wakaba 1.1 package Whatpm::Charset::DecodeHandle::Encode;
618    
619 wakaba 1.7 ## NOTE: Provides a Perl |Encode| module wrapper object.
620    
621 wakaba 1.1 sub charset ($) { $_[0]->{charset} }
622    
623 wakaba 1.3 sub close ($) { $_[0]->{filehandle}->close }
624 wakaba 1.1
625     sub getc ($) {
626 wakaba 1.9 my $c = '';
627     my $l = $_[0]->read ($c, 1);
628     if ($l) {
629     return $c;
630     } else {
631     return undef;
632     }
633     } # getc
634    
635     sub read ($$$;$) {
636 wakaba 1.1 my $self = $_[0];
637 wakaba 1.14 #my $scalar = $_[1];
638     my $length = $_[2];
639     my $offset = $_[3] || 0;
640     my $count = 0;
641     my $eof;
642     ## NOTE: It is incompatible with the standard Perl semantics
643     ## if $offset is greater than the length of $scalar.
644    
645     A: {
646     return $count if $length < 1;
647    
648     if (my $l = (length ${$self->{char_buffer}}) - $self->{char_buffer_pos}) {
649     if ($l >= $length) {
650     substr ($_[1], $offset)
651     = substr (${$self->{char_buffer}}, $self->{char_buffer_pos},
652     $length);
653     $count += $length;
654     $self->{char_buffer_pos} += $length;
655     $length = 0;
656     return $count;
657     } else {
658     substr ($_[1], $offset)
659     = substr (${$self->{char_buffer}}, $self->{char_buffer_pos});
660     $count += $l;
661     $length -= $l;
662     ${$self->{char_buffer}} = '';
663     $self->{char_buffer_pos} = 0;
664     }
665     $offset = length $_[1];
666     }
667 wakaba 1.1
668 wakaba 1.14 if ($eof) {
669     return $count;
670 wakaba 1.1 }
671 wakaba 1.14
672     my $error;
673     if ($self->{continue}) {
674     if ($self->{filehandle}->read ($self->{byte_buffer}, 256,
675     length $self->{byte_buffer})) {
676     #
677     } else {
678     $error = 1;
679     }
680     $self->{continue} = 0;
681     } elsif (512 > length $self->{byte_buffer}) {
682     if ($self->{filehandle}->read ($self->{byte_buffer}, 256,
683     length $self->{byte_buffer})) {
684     #
685     } else {
686     $eof = 1;
687 wakaba 1.1 }
688 wakaba 1.14 }
689    
690     unless ($error) {
691 wakaba 1.15 if (not $self->{bom_checked}) {
692     if (defined $self->{bom_pattern}) {
693     if ($self->{byte_buffer} =~ s/^$self->{bom_pattern}//) {
694     $self->{has_bom} = 1;
695     }
696     }
697     $self->{bom_checked} = 1;
698     }
699    
700 wakaba 1.14 my $string = Encode::decode ($self->{perl_encoding_name},
701     $self->{byte_buffer},
702     Encode::FB_QUIET ());
703     if (length $string) {
704     $self->{char_buffer} = \$string;
705     $self->{char_buffer_pos} = 0;
706     if (length $self->{byte_buffer}) {
707     $self->{continue} = 1;
708     }
709 wakaba 1.1 } else {
710 wakaba 1.14 if (length $self->{byte_buffer}) {
711     $error = 1;
712     } else {
713     ## NOTE: No further input.
714     redo A;
715     }
716 wakaba 1.1 }
717     }
718    
719 wakaba 1.14 if ($error) {
720     my $r = substr $self->{byte_buffer}, 0, 1, '';
721 wakaba 1.15 my $fallback;
722 wakaba 1.14 my $etype = 'illegal-octets-error';
723 wakaba 1.15 my %earg;
724     if ($self->{category}
725 wakaba 1.16 & Message::Charset::Info::CHARSET_CATEGORY_SJIS) {
726     if ($r =~ /^[\x81-\x9F\xE0-\xFC]/) {
727     if ($self->{byte_buffer} =~ s/(.)//s) {
728     $r .= $1; # not limited to \x40-\xFC - \x7F
729     $etype = 'unassigned-code-point-error';
730     }
731     ## NOTE: Range [\xF0-\xFC] is unassigned and may be used as a
732     ## single-byte character or as the first-byte of a double-byte
733     ## character, according to JIS X 0208:1997 Appendix 1. However, the
734     ## current practice is using the range as first-bytes of double-byte
735     ## characters.
736     } elsif ($r =~ /^[\x80\xA0\xFD-\xFF]/) {
737     $etype = 'unassigned-code-point-error';
738     }
739     } elsif ($self->{category}
740     & Message::Charset::Info::CHARSET_CATEGORY_EUCJP) {
741 wakaba 1.15 if ($r =~ /^[\xA1-\xFE]/) {
742     if ($self->{byte_buffer} =~ s/^([\xA1-\xFE])//) {
743     $r .= $1;
744     $etype = 'unassigned-code-point-error';
745     }
746     } elsif ($r eq "\x8F") {
747     if ($self->{byte_buffer} =~ s/^([\xA1-\xFE][\xA1-\xFE]?)//) {
748     $r .= $1;
749     $etype = 'unassigned-code-point-error' if length $1 == 2;
750     }
751     } elsif ($r eq "\x8E") {
752     if ($self->{byte_buffer} =~ s/^([\xA1-\xFE])//) {
753     $r .= $1;
754     $etype = 'unassigned-code-point-error';
755     }
756     } elsif ($r eq "\xA0" or $r eq "\xFF") {
757 wakaba 1.14 $etype = 'unassigned-code-point-error';
758     }
759 wakaba 1.15 } else {
760     $fallback = $self->{fallback}->{$r};
761     if (defined $fallback) {
762     ## NOTE: This is an HTML5 parse error.
763     $etype = 'fallback-char-error';
764     $earg{char} = \$fallback;
765     } elsif (exists $self->{fallback}->{$r}) {
766     ## NOTE: This is an HTML5 parse error. In addition, the octet
767     ## is not assigned with a character.
768     $etype = 'fallback-unassigned-error';
769 wakaba 1.14 }
770 wakaba 1.1 }
771 wakaba 1.15
772 wakaba 1.14 ## NOTE: Fixup line/column number by counting the number of
773     ## lines/columns in the string that is to be retuend by this
774     ## method call.
775     my $line_diff = 0;
776     my $col_diff = 0;
777     my $set_col;
778     for (my $i = 0; $i < $count; $i++) {
779     my $s = substr $_[1], $i - $count, 1;
780     if ($s eq "\x0D") {
781     $line_diff++;
782     $col_diff = 0;
783     $set_col = 1;
784     $i++ if substr ($_[1], $i - $count + 1, 1) eq "\x0A";
785     } elsif ($s eq "\x0A") {
786     $line_diff++;
787     $col_diff = 0;
788     $set_col = 1;
789     } else {
790     $col_diff++;
791     }
792     }
793     my $i = $self->{char_buffer_pos};
794     if ($count and substr (${$self->{char_buffer}}, -1, 1) eq "\x0D") {
795     if (substr (${$self->{char_buffer}}, $i, 1) eq "\x0A") {
796     $i++;
797     }
798 wakaba 1.1 }
799 wakaba 1.14 my $cb_length = length ${$self->{char_buffer}};
800     for (; $i < $cb_length; $i++) {
801     my $s = substr $_[1], $i, 1;
802     if ($s eq "\x0D") {
803     $line_diff++;
804     $col_diff = 0;
805     $set_col = 1;
806     $i++ if substr ($_[1], $i + 1, 1) eq "\x0A";
807     } elsif ($s eq "\x0A") {
808     $line_diff++;
809     $col_diff = 0;
810     $set_col = 1;
811     } else {
812     $col_diff++;
813     }
814 wakaba 1.1 }
815 wakaba 1.15 $self->{onerror}->($self, $etype, octets => \$r, %earg,
816 wakaba 1.14 level => $self->{level}->{$self->{error_level}->{$etype}},
817     line_diff => $line_diff,
818     ($set_col ? (column => 1) : ()),
819     column_diff => $col_diff);
820     ## NOTE: Error handler may modify |octets| parameter, which
821     ## would be returned as part of the output. Note that what
822     ## is returned would affect what |manakai_read_until| returns.
823 wakaba 1.15 ${$self->{char_buffer}} .= defined $fallback ? $fallback : $r;
824 wakaba 1.1 }
825    
826 wakaba 1.14 redo A;
827     } # A
828 wakaba 1.9 } # read
829    
830 wakaba 1.15 sub manakai_read_until ($$$;$) {
831     #my ($self, $scalar, $pattern, $offset) = @_;
832     my $self = $_[0];
833     my $s = '';
834     $self->read ($s, 255);
835     if ($s =~ /^(?>$_[2])+/) {
836     my $rem_length = (length $s) - $+[0];
837     if ($rem_length) {
838     if ($self->{char_buffer_pos} > $rem_length) {
839     $self->{char_buffer_pos} -= $rem_length;
840     } else {
841     substr (${$self->{char_buffer}}, 0, $self->{char_buffer_pos})
842     = substr ($s, $+[0]);
843     $self->{char_buffer_pos} = 0;
844     }
845     }
846     substr ($_[1], $_[3]) = substr ($s, $-[0], $+[0] - $-[0]);
847     return $+[0];
848     } elsif (length $s) {
849     if ($self->{char_buffer_pos} > length $s) {
850     $self->{char_buffer_pos} -= length $s;
851     } else {
852     substr (${$self->{char_buffer}}, 0, $self->{char_buffer_pos}) = $s;
853     $self->{char_buffer_pos} = 0;
854     }
855     }
856     return 0;
857     } # manakai_read_until
858    
859     sub has_bom ($) { $_[0]->{has_bom} }
860    
861     sub input_encoding ($) {
862     my $v = $_[0]->{input_encoding};
863     return $v if defined $v;
864    
865     my $uri = $_[0]->{charset};
866     if (defined $uri) {
867     return Whatpm::Charset::DecodeHandle->uri_to_name (xml => $uri);
868     }
869    
870     return undef;
871     } # input_encoding
872    
873     sub onerror ($;$) {
874     if (@_ > 1) {
875     $_[0]->{onerror} = $_[1];
876     }
877    
878     return $_[0]->{onerror};
879     } # onerror
880    
881     sub ungetc ($$) {
882     unshift @{$_[0]->{character_queue}}, chr int ($_[1] or 0);
883     } # ungetc
884    
885 wakaba 1.1 package Whatpm::Charset::DecodeHandle::ISO2022JP;
886     push our @ISA, 'Whatpm::Charset::DecodeHandle::Encode';
887    
888     sub getc ($) {
889     my $self = $_[0];
890     return shift @{$self->{character_queue}} if @{$self->{character_queue}};
891    
892     my $r;
893     A: {
894     my $error;
895     if ($self->{continue}) {
896 wakaba 1.3 if ($self->{filehandle}->read ($self->{byte_buffer}, 256,
897     length $self->{byte_buffer})) {
898 wakaba 1.1 #
899     } else {
900     $error = 1;
901     }
902     $self->{continue} = 0;
903     } elsif (512 > length $self->{byte_buffer}) {
904 wakaba 1.3 $self->{filehandle}->read ($self->{byte_buffer}, 256,
905     length $self->{byte_buffer});
906 wakaba 1.1 }
907    
908     unless ($error) {
909     if ($self->{byte_buffer} =~ s/^\x1B(\x24[\x40\x42]|\x28[\x42\x4A])//) {
910     $self->{state} = {
911     "\x24\x40" => 'state_2440',
912     "\x24\x42" => 'state_2442',
913     "\x28\x42" => 'state_2842',
914     "\x28\x4A" => 'state_284A',
915     }->{$1};
916     redo A;
917     } elsif ($self->{state} eq 'state_2842') { # IRV
918     if ($self->{byte_buffer} =~ s/^([\x00-\x0D\x10-\x1A\x1C-\x7F]+)//) {
919     push @{$self->{character_queue}}, split //, $1;
920     $r = shift @{$self->{character_queue}};
921     } else {
922     if (length $self->{byte_buffer}) {
923     $error = 1;
924     } else {
925     $r = undef;
926     }
927     }
928     } elsif ($self->{state} eq 'state_284A') { # 0201
929     if ($self->{byte_buffer} =~ s/^([\x00-\x0D\x10-\x1A\x1C-\x7F]+)//) {
930     my $v = $1;
931     $v =~ tr/\x5C\x7E/\xA5\x{203E}/;
932     push @{$self->{character_queue}}, split //, $v;
933     $r = shift @{$self->{character_queue}};
934     } else {
935     if (length $self->{byte_buffer}) {
936     $error = 1;
937     } else {
938     $r = undef;
939     $self->{onerror}->($self, 'invalid-state-error',
940 wakaba 1.7 state => $self->{state},
941     level => $self->{level}->{$self->{error_level}->{'invalid-state-error'}});
942 wakaba 1.1 }
943     }
944     } elsif ($self->{state} eq 'state_2442') { # 1983
945     my $v = Encode::decode ($self->{state_2442},
946     $self->{byte_buffer},
947     Encode::FB_QUIET ());
948     if (length $v) {
949     push @{$self->{character_queue}}, split //, $v;
950     $r = shift @{$self->{character_queue}};
951     } else {
952     if (length $self->{byte_buffer}) {
953     $error = 1;
954     } else {
955     $r = undef;
956     $self->{onerror}->($self, 'invalid-state-error',
957 wakaba 1.7 state => $self->{state},
958     level => $self->{level}->{$self->{error_level}->{'invalid-state-error'}});
959 wakaba 1.1 }
960     }
961     } elsif ($self->{state} eq 'state_2440') { # 1978
962     my $v = Encode::decode ($self->{state_2440},
963     $self->{byte_buffer},
964     Encode::FB_QUIET ());
965     if (length $v) {
966     push @{$self->{character_queue}}, split //, $v;
967     $r = shift @{$self->{character_queue}};
968     } else {
969     if (length $self->{byte_buffer}) {
970     $error = 1;
971     } else {
972     $r = undef;
973     $self->{onerror}->($self, 'invalid-state-error',
974 wakaba 1.7 state => $self->{state},
975     level => $self->{level}->{$self->{error_level}->{'invalid-state-error'}});
976 wakaba 1.1 }
977     }
978     } else {
979     $error = 1;
980     }
981     }
982    
983     if ($error) {
984     $r = substr $self->{byte_buffer}, 0, 1, '';
985     my $etype = 'illegal-octets-error';
986     if (($self->{state} eq 'state_2442' or
987     $self->{state} eq 'state_2440') and
988     $r =~ /^[\x21-\x7E]/ and
989     $self->{byte_buffer} =~ s/^([\x21-\x7E])//) {
990     $r .= $1;
991     $etype = 'unassigned-code-point-error';
992     } elsif ($r eq "\x1B" and
993     $self->{byte_buffer} =~ s/^\(H//) { # Old 0201
994     $r .= "(H";
995     $self->{state} = 'state_284A';
996     }
997 wakaba 1.7 $self->{onerror}->($self, $etype, octets => \$r,
998     level => $self->{level}->{$self->{error_level}->{$etype}});
999 wakaba 1.1 }
1000     } # A
1001    
1002     return $r;
1003     } # getc
1004    
1005 wakaba 1.9 ## TODO: This is not good for performance. Should be replaced
1006     ## by read-centric implementation.
1007     sub read ($$$;$) {
1008     #my ($self, $scalar, $length, $offset) = @_;
1009     my $length = $_[2];
1010     my $r = '';
1011     while ($length > 0) {
1012     my $c = $_[0]->getc;
1013     last unless defined $c;
1014     $r .= $c;
1015     $length--;
1016     }
1017     substr ($_[1], $_[3]) = $r;
1018     ## NOTE: This would do different thing from what Perl's |read| do
1019     ## if $offset points beyond the end of the $scalar.
1020     return length $r;
1021     } # read
1022    
1023 wakaba 1.12 sub manakai_read_until ($$$;$) {
1024     #my ($self, $scalar, $pattern, $offset) = @_;
1025     my $self = $_[0];
1026 wakaba 1.11 my $c = $self->getc;
1027 wakaba 1.12 if ($c =~ /^$_[2]/) {
1028     substr ($_[1], $_[3]) = $c;
1029     return 1;
1030 wakaba 1.11 } elsif (defined $c) {
1031     $self->ungetc (ord $c);
1032 wakaba 1.12 return 0;
1033 wakaba 1.11 } else {
1034 wakaba 1.12 return 0;
1035 wakaba 1.11 }
1036 wakaba 1.12 } # manakai_read_until
1037 wakaba 1.11
1038 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:us-ascii'} =
1039     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:us'} =
1040     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:iso646-us'} =
1041     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:cp367'} =
1042     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:ibm367'} =
1043     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:ansi_x3.4-1986'} =
1044     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:ansi_x3.4-1968'} =
1045     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:iso-ir-6'} =
1046     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:csascii'} =
1047     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:iso_646.irv:1991'} =
1048     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:ascii'} = {ascii8 =>
1049     '1',
1050     is_block_safe =>
1051     '1',
1052     ietf_name =>
1053     ['ansi_x3.4-1968',
1054     'ansi_x3.4-1986',
1055     'ascii',
1056     'cp367',
1057     'csascii',
1058     'ibm367',
1059     'iso-ir-6',
1060     'iso646-us',
1061     'iso_646.irv:1991',
1062     'us',
1063     'us-ascii',
1064     'us-ascii'],
1065     mime_name =>
1066     'us-ascii',
1067     perl_name =>
1068     ['ascii',
1069     'iso-646-us',
1070     'us-ascii'],
1071     utf8_encoding_scheme =>
1072     '1',
1073     'uri',
1074     {'urn:x-suika-fam-cx:charset:ansi_x3.4-1968',
1075     '1',
1076     'urn:x-suika-fam-cx:charset:ansi_x3.4-1986',
1077     '1',
1078     'urn:x-suika-fam-cx:charset:ascii',
1079     '1',
1080     'urn:x-suika-fam-cx:charset:cp367',
1081     '1',
1082     'urn:x-suika-fam-cx:charset:csascii',
1083     '1',
1084     'urn:x-suika-fam-cx:charset:ibm367',
1085     '1',
1086     'urn:x-suika-fam-cx:charset:iso-ir-6',
1087     '1',
1088     'urn:x-suika-fam-cx:charset:iso646-us',
1089     '1',
1090     'urn:x-suika-fam-cx:charset:iso_646.irv:1991',
1091     '1',
1092     'urn:x-suika-fam-cx:charset:us',
1093     '1',
1094     'urn:x-suika-fam-cx:charset:us-ascii',
1095     '1'},
1096 wakaba 1.2 };
1097    
1098 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.ascii-ctrl'} = {perl_name =>
1099     ['ascii-ctrl'],
1100     'uri',
1101     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.ascii-ctrl',
1102     '1'}};
1103     $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.null'} = {perl_name =>
1104     ['null'],
1105     'uri',
1106     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.null',
1107     '1'}};
1108     $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.utf-8'} = {ascii8 =>
1109     '1',
1110     bom_allowed =>
1111     '1',
1112     no_bom_variant =>
1113     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf8',
1114     utf8_encoding_scheme =>
1115     '1',
1116     'uri',
1117     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.utf-8',
1118     '1'},
1119 wakaba 1.2 xml_name => 'UTF-8',
1120     };
1121    
1122 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/UTF-8.RFC2279'} = {ascii8 =>
1123     '1',
1124     bom_allowed =>
1125     '1',
1126     no_bom_variant =>
1127     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf8',
1128     utf8_encoding_scheme =>
1129     '1',
1130     'uri',
1131     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/UTF-8.RFC2279',
1132     '1'}};
1133     $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-8'} = {
1134     ascii8 => 1,
1135     is_block_safe =>
1136     '1',
1137     perl_name =>
1138     ['utf-8'],
1139     utf8_encoding_scheme =>
1140     '1',
1141     'uri',
1142     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-8',
1143     '1'}};
1144     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:utf-8'} = {
1145     ascii8 => 1,
1146     bom_allowed =>
1147     '1',
1148     no_bom_variant =>
1149     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-8',
1150     ietf_name =>
1151     ['utf-8'],
1152     mime_name =>
1153     'utf-8',
1154     utf8_encoding_scheme =>
1155     '1',
1156     'uri',
1157     {'urn:x-suika-fam-cx:charset:utf-8',
1158     '1'},
1159 wakaba 1.2 };
1160    
1161 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf8'} = {ascii8 =>
1162     '1',
1163     is_block_safe =>
1164     '1',
1165     perl_name =>
1166     ['utf8'],
1167     utf8_encoding_scheme =>
1168     '1',
1169     'uri',
1170     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf8',
1171     '1'}};
1172     $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.utf-16'} = {
1173     ascii16 => 1,
1174     bom_allowed =>
1175     '1',
1176     bom_required =>
1177     '1',
1178     no_bom_variant =>
1179     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16le',
1180     no_bom_variant16be =>
1181     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16be',
1182     no_bom_variant16le =>
1183     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16le',
1184     perl_name =>
1185     ['utf-16'],
1186     'uri',
1187     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.utf-16',
1188     '1'},
1189 wakaba 1.2 xml_name => 'UTF-16',
1190     };
1191    
1192 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:utf-16'} = {
1193     ascii16 => 1,
1194     bom_allowed =>
1195     '1',
1196     no_bom_variant =>
1197     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16le',
1198     no_bom_variant16be =>
1199     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16be',
1200     no_bom_variant16le =>
1201     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16le',
1202     ietf_name =>
1203     ['utf-16'],
1204     mime_name =>
1205     'utf-16',
1206     'uri',
1207     {'urn:x-suika-fam-cx:charset:utf-16',
1208     '1'},
1209 wakaba 1.2 };
1210    
1211 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:utf-16be'} = {
1212     ascii16 => 1,
1213     ascii16be => 1,
1214     bom_allowed =>
1215     '1',
1216     no_bom_variant =>
1217     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16be',
1218     no_bom_variant16be =>
1219     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16be',
1220     ietf_name =>
1221     ['utf-16be'],
1222     mime_name =>
1223     'utf-16be',
1224     'uri',
1225     {'urn:x-suika-fam-cx:charset:utf-16be',
1226     '1'},
1227 wakaba 1.2 };
1228    
1229 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:utf-16le'} = {
1230     ascii16 => 1,
1231     ascii16le => 1,
1232     bom_allowed =>
1233     '1',
1234     no_bom_variant =>
1235     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16le',
1236     no_bom_variant16le =>
1237     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16le',
1238     ietf_name =>
1239     ['utf-16le'],
1240     mime_name =>
1241     'utf-16le',
1242     'uri',
1243     {'urn:x-suika-fam-cx:charset:utf-16le',
1244     '1'},
1245 wakaba 1.2 };
1246    
1247 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16be'} = {
1248     ascii16 => 1,
1249     ascii16be => 1,
1250     is_block_safe =>
1251     '1',
1252     perl_name =>
1253     ['utf-16be'],
1254     'uri',
1255     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16be',
1256     '1'}};
1257     $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16le'} = {
1258     ascii16 => 1,
1259     ascii16le => 1,
1260     is_block_safe =>
1261     '1',
1262     perl_name =>
1263     ['utf-16le'],
1264     'uri',
1265     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-16le',
1266     '1'}};
1267     $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-10646-ucs-2'} = $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:iso-10646-ucs-2'} = {
1268     ascii16 => 1,
1269     bom_allowed =>
1270     '1',
1271     no_bom_variant =>
1272     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.ucs-2le',
1273     no_bom_variant16be =>
1274     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.ucs-2be',
1275     no_bom_variant16le =>
1276     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.ucs-2le',
1277     ietf_name =>
1278     ['csunicode',
1279     'iso-10646-ucs-2'],
1280     mime_name =>
1281     'iso-10646-ucs-2',
1282     'uri',
1283     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-10646-ucs-2',
1284     '1',
1285     'urn:x-suika-fam-cx:charset:iso-10646-ucs-2',
1286     '1'},
1287 wakaba 1.2 xml_name => 'ISO-10646-UCS-2',
1288     };
1289    
1290 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.ucs-2be'} = {
1291     ascii16 => 1,
1292     ascii16be => 1,
1293     is_block_safe =>
1294     '1',
1295     perl_name =>
1296     ['ucs-2be'],
1297     'uri',
1298     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.ucs-2be',
1299     '1'}};
1300     $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.ucs-2le'} = {
1301     ascii16 => 1,
1302     ascii16le => 1,
1303     is_block_safe =>
1304     '1',
1305     perl_name =>
1306     ['ucs-2le'],
1307     'uri',
1308     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.ucs-2le',
1309     '1'}};
1310     $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-10646-ucs-4'} = $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:iso-10646-ucs-4'} = {
1311     ascii32 => 1,
1312     bom_allowed =>
1313     '1',
1314     no_bom_variant =>
1315     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-32le',
1316     no_bom_variant32endian1234 =>
1317     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-32be',
1318     no_bom_variant32endian4321 =>
1319     'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-32le',
1320     ietf_name =>
1321     ['csucs4',
1322     'iso-10646-ucs-4'],
1323     mime_name =>
1324     'iso-10646-ucs-4',
1325     'uri',
1326     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-10646-ucs-4',
1327     '1',
1328     'urn:x-suika-fam-cx:charset:iso-10646-ucs-4',
1329     '1'},
1330 wakaba 1.2 xml_name => 'ISO-10646-UCS-4',
1331     };
1332    
1333 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-32be'} = {
1334     ascii32 => 1,
1335     ascii32endian1234 => 1,
1336     is_block_safe =>
1337     '1',
1338     perl_name =>
1339     ['ucs-4be',
1340     'utf-32be'],
1341     'uri',
1342     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-32be',
1343     '1'}};
1344     $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-32le'} = {
1345     ascii32 => 1,
1346     ascii32endian4321 => 1,
1347     is_block_safe =>
1348     '1',
1349     perl_name =>
1350     ['ucs-4le',
1351     'utf-32le'],
1352     'uri',
1353     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.utf-32le',
1354     '1'}};
1355     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:iso_8859-1:1987'} = $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-1'} = {ascii8 =>
1356     '1',
1357     is_block_safe =>
1358     '1',
1359     ietf_name =>
1360     ['cp819',
1361     'csisolatin1',
1362     'ibm819',
1363     'iso-8859-1',
1364     'iso-8859-1',
1365     'iso-ir-100',
1366     'iso_8859-1',
1367     'iso_8859-1:1987',
1368     'l1',
1369     'latin1'],
1370     mime_name =>
1371     'iso-8859-1',
1372     perl_name =>
1373     ['iso-8859-1',
1374     'latin1'],
1375     'uri',
1376     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-1',
1377     '1',
1378     'urn:x-suika-fam-cx:charset:iso_8859-1:1987',
1379     '1'},
1380 wakaba 1.2 xml_name => 'ISO-8859-1',
1381     };
1382    
1383 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-2'} = {ascii8 =>
1384     '1',
1385     is_block_safe =>
1386     '1',
1387     'uri',
1388     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-2',
1389     '1'},
1390 wakaba 1.2 xml_name => 'ISO-8859-2',
1391     };
1392    
1393 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-3'} = {ascii8 =>
1394     '1',
1395     is_block_safe =>
1396     '1',
1397     'uri',
1398     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-3',
1399     '1'},
1400 wakaba 1.2 xml_name => 'ISO-8859-3',
1401     };
1402    
1403 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-4'} = {ascii8 =>
1404     '1',
1405     is_block_safe =>
1406     '1',
1407     'uri',
1408     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-4',
1409     '1'},
1410 wakaba 1.2 xml_name => 'ISO-8859-4',
1411     };
1412    
1413 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-5'} = {ascii8 =>
1414     '1',
1415     is_block_safe =>
1416     '1',
1417     'uri',
1418     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-5',
1419     '1'},
1420 wakaba 1.2 xml_name => 'ISO-8859-5',
1421     };
1422    
1423 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-6'} = {ascii8 =>
1424     '1',
1425     is_block_safe =>
1426     '1',
1427     'uri',
1428     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-6',
1429     '1'},
1430 wakaba 1.2 xml_name => 'ISO-8859-6',
1431     };
1432    
1433 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-7'} = {ascii8 =>
1434     '1',
1435     is_block_safe =>
1436     '1',
1437     'uri',
1438     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-7',
1439     '1'},
1440 wakaba 1.2 xml_name => 'ISO-8859-7',
1441     };
1442    
1443 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-8'} = {ascii8 =>
1444     '1',
1445     is_block_safe =>
1446     '1',
1447     'uri',
1448     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-8',
1449     '1'},
1450 wakaba 1.2 xml_name => 'ISO-8859-8',
1451     };
1452    
1453 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-9'} = {ascii8 =>
1454     '1',
1455     is_block_safe =>
1456     '1',
1457     'uri',
1458     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-9',
1459     '1'},
1460 wakaba 1.2 xml_name => 'ISO-8859-9',
1461     };
1462    
1463 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-10'} = {ascii8 =>
1464     '1',
1465     is_block_safe =>
1466     '1',
1467     'uri',
1468     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-10',
1469     '1'},
1470 wakaba 1.2 xml_name => 'ISO-8859-10',
1471     };
1472    
1473 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-11'} = {ascii8 =>
1474     '1',
1475     is_block_safe =>
1476     '1',
1477     'uri',
1478     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-11',
1479     '1'},
1480 wakaba 1.2 xml_name => 'ISO-8859-11',
1481     };
1482    
1483 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-13'} = {ascii8 =>
1484     '1',
1485     is_block_safe =>
1486     '1',
1487     'uri',
1488     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-13',
1489     '1'},
1490 wakaba 1.2 xml_name => 'ISO-8859-13',
1491     };
1492    
1493 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-14'} = {ascii8 =>
1494     '1',
1495     is_block_safe =>
1496     '1',
1497     'uri',
1498     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-14',
1499     '1'},
1500 wakaba 1.2 xml_name => 'ISO-8859-14',
1501     };
1502    
1503 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-15'} = {ascii8 =>
1504     '1',
1505     is_block_safe =>
1506     '1',
1507     'uri',
1508     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-15',
1509     '1'},
1510 wakaba 1.2 xml_name => 'ISO-8859-15',
1511     };
1512    
1513 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-16'} = {ascii8 =>
1514     '1',
1515     is_block_safe =>
1516     '1',
1517     'uri',
1518     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-8859-16',
1519     '1'},
1520 wakaba 1.2 xml_name => 'ISO-8859-16',
1521     };
1522    
1523 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-2022-jp'} = {ascii8 =>
1524     '1',
1525     'uri',
1526     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.iso-2022-jp',
1527     '1'},
1528 wakaba 1.2 xml_name => 'ISO-2022-JP',
1529     };
1530    
1531 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:iso-2022-jp'} = {ascii8 =>
1532     '1',
1533     ietf_name =>
1534     ['csiso2022jp',
1535     'iso-2022-jp',
1536     'iso-2022-jp'],
1537     mime_name =>
1538     'iso-2022-jp',
1539     'uri',
1540     {'urn:x-suika-fam-cx:charset:iso-2022-jp',
1541     '1'},
1542 wakaba 1.2 };
1543    
1544 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.iso-2022-jp'} = {ascii8 =>
1545     '1',
1546     perl_name =>
1547     ['iso-2022-jp'],
1548     'uri',
1549     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.iso-2022-jp',
1550     '1'}};
1551     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:shift_jis'} = $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.shift_jis'} = {ascii8 =>
1552     '1',
1553     is_block_safe =>
1554     '1',
1555     ietf_name =>
1556     ['csshiftjis',
1557     'ms_kanji',
1558     'shift_jis',
1559     'shift_jis'],
1560     mime_name =>
1561     'shift_jis',
1562     perl_name =>
1563     ['shift-jis-1997'],
1564     'uri',
1565     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.shift_jis',
1566     '1',
1567     'urn:x-suika-fam-cx:charset:shift_jis',
1568     '1'},
1569 wakaba 1.2 xml_name => 'Shift_JIS',
1570     };
1571    
1572 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.shiftjis'} = {ascii8 =>
1573     '1',
1574     is_block_safe =>
1575     '1',
1576     perl_name =>
1577     ['shiftjis',
1578     'sjis'],
1579     'uri',
1580     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.shiftjis',
1581     '1'}};
1582     $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:euc-jp'} = $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.euc-jp'} = $Whatpm::Charset::CharsetDef->{'urn:x-suika-fam-cx:charset:extended_unix_code_packed_format_for_japanese'} = {ascii8 =>
1583     '1',
1584     is_block_safe =>
1585     '1',
1586     ietf_name =>
1587     ['cseucpkdfmtjapanese',
1588     'euc-jp',
1589     'euc-jp',
1590     'extended_unix_code_packed_format_for_japanese'],
1591     mime_name =>
1592     'euc-jp',
1593     perl_name =>
1594     ['euc-jp-1997'],
1595     'uri',
1596     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/XML.euc-jp',
1597     '1',
1598     'urn:x-suika-fam-cx:charset:euc-jp',
1599     '1',
1600     'urn:x-suika-fam-cx:charset:extended_unix_code_packed_format_for_japanese',
1601     '1'},
1602 wakaba 1.2 xml_name => 'EUC-JP',
1603     };
1604    
1605 wakaba 1.1 $Whatpm::Charset::CharsetDef->{'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.euc-jp'} = {ascii8 =>
1606     '1',
1607     is_block_safe =>
1608     '1',
1609     perl_name =>
1610     ['euc-jp',
1611     'ujis'],
1612     'uri',
1613     {'http://suika.fam.cx/~wakaba/archive/2004/dis/Charset/Perl.euc-jp',
1614     '1'}};
1615    
1616     1;
1617 wakaba 1.16 ## $Date: 2008/09/14 06:58:28 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24