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