nx_charset_test.nx source
↩ module page · 580 lines · 20088 B
1// nx_charset_test.nx -- charset transcode + detect + sniff(meta) + render KAT.
2// expect_exit: 0
3// license_tier: ORIGINAL
4
5import "nx_syscalls.nx"
6import "nx_charset.nx"
7import "nx_html_to_text.nx"
8
9func cs_eq(g: *u8, gn: i64, e: *u8, en: i64) -> i64 {
10 if gn != en { return 0 }
11 var i: i64 = 0
12 while i < gn { if (g[i]&0xff)!=(e[i]&0xff) { return 0 } i = i + 1 }
13 return 1
14}
15
16func main() -> i64 {
17 let i_lat1_eacute: *u8 = (sys_mmap(9)) as *u8
18 i_lat1_eacute[0] = 0xe9 as u8
19 let e_lat1_eacute: *u8 = (sys_mmap(10)) as *u8
20 e_lat1_eacute[0] = 0xc3 as u8
21 e_lat1_eacute[1] = 0xa9 as u8
22 let o_lat1_eacute: *u8 = (sys_mmap(64)) as *u8
23 let n_lat1_eacute: i64 = nx_charset_to_utf8(i_lat1_eacute, 1, 1, o_lat1_eacute, 64)
24 if cs_eq(o_lat1_eacute, n_lat1_eacute, e_lat1_eacute, 2) != 1 { return 100 }
25
26 let i_lat1_ascii: *u8 = (sys_mmap(9)) as *u8
27 i_lat1_ascii[0] = 0x41 as u8
28 let e_lat1_ascii: *u8 = (sys_mmap(9)) as *u8
29 e_lat1_ascii[0] = 0x41 as u8
30 let o_lat1_ascii: *u8 = (sys_mmap(64)) as *u8
31 let n_lat1_ascii: i64 = nx_charset_to_utf8(i_lat1_ascii, 1, 1, o_lat1_ascii, 64)
32 if cs_eq(o_lat1_ascii, n_lat1_ascii, e_lat1_ascii, 1) != 1 { return 101 }
33
34 let i_lat1_cafe: *u8 = (sys_mmap(12)) as *u8
35 i_lat1_cafe[0] = 0x43 as u8
36 i_lat1_cafe[1] = 0x61 as u8
37 i_lat1_cafe[2] = 0x66 as u8
38 i_lat1_cafe[3] = 0xe9 as u8
39 let e_lat1_cafe: *u8 = (sys_mmap(13)) as *u8
40 e_lat1_cafe[0] = 0x43 as u8
41 e_lat1_cafe[1] = 0x61 as u8
42 e_lat1_cafe[2] = 0x66 as u8
43 e_lat1_cafe[3] = 0xc3 as u8
44 e_lat1_cafe[4] = 0xa9 as u8
45 let o_lat1_cafe: *u8 = (sys_mmap(64)) as *u8
46 let n_lat1_cafe: i64 = nx_charset_to_utf8(i_lat1_cafe, 4, 1, o_lat1_cafe, 64)
47 if cs_eq(o_lat1_cafe, n_lat1_cafe, e_lat1_cafe, 5) != 1 { return 102 }
48
49 let i_w1252_lsquo: *u8 = (sys_mmap(9)) as *u8
50 i_w1252_lsquo[0] = 0x91 as u8
51 let e_w1252_lsquo: *u8 = (sys_mmap(11)) as *u8
52 e_w1252_lsquo[0] = 0xe2 as u8
53 e_w1252_lsquo[1] = 0x80 as u8
54 e_w1252_lsquo[2] = 0x98 as u8
55 let o_w1252_lsquo: *u8 = (sys_mmap(64)) as *u8
56 let n_w1252_lsquo: i64 = nx_charset_to_utf8(i_w1252_lsquo, 1, 2, o_w1252_lsquo, 64)
57 if cs_eq(o_w1252_lsquo, n_w1252_lsquo, e_w1252_lsquo, 3) != 1 { return 103 }
58
59 let i_w1252_euro: *u8 = (sys_mmap(9)) as *u8
60 i_w1252_euro[0] = 0x80 as u8
61 let e_w1252_euro: *u8 = (sys_mmap(11)) as *u8
62 e_w1252_euro[0] = 0xe2 as u8
63 e_w1252_euro[1] = 0x82 as u8
64 e_w1252_euro[2] = 0xac as u8
65 let o_w1252_euro: *u8 = (sys_mmap(64)) as *u8
66 let n_w1252_euro: i64 = nx_charset_to_utf8(i_w1252_euro, 1, 2, o_w1252_euro, 64)
67 if cs_eq(o_w1252_euro, n_w1252_euro, e_w1252_euro, 3) != 1 { return 104 }
68
69 let i_w1252_mdash: *u8 = (sys_mmap(9)) as *u8
70 i_w1252_mdash[0] = 0x97 as u8
71 let e_w1252_mdash: *u8 = (sys_mmap(11)) as *u8
72 e_w1252_mdash[0] = 0xe2 as u8
73 e_w1252_mdash[1] = 0x80 as u8
74 e_w1252_mdash[2] = 0x94 as u8
75 let o_w1252_mdash: *u8 = (sys_mmap(64)) as *u8
76 let n_w1252_mdash: i64 = nx_charset_to_utf8(i_w1252_mdash, 1, 2, o_w1252_mdash, 64)
77 if cs_eq(o_w1252_mdash, n_w1252_mdash, e_w1252_mdash, 3) != 1 { return 105 }
78
79 let i_w1252_latin: *u8 = (sys_mmap(9)) as *u8
80 i_w1252_latin[0] = 0xe9 as u8
81 let e_w1252_latin: *u8 = (sys_mmap(10)) as *u8
82 e_w1252_latin[0] = 0xc3 as u8
83 e_w1252_latin[1] = 0xa9 as u8
84 let o_w1252_latin: *u8 = (sys_mmap(64)) as *u8
85 let n_w1252_latin: i64 = nx_charset_to_utf8(i_w1252_latin, 1, 2, o_w1252_latin, 64)
86 if cs_eq(o_w1252_latin, n_w1252_latin, e_w1252_latin, 2) != 1 { return 106 }
87
88 let i_w1252_ascii: *u8 = (sys_mmap(9)) as *u8
89 i_w1252_ascii[0] = 0x5a as u8
90 let e_w1252_ascii: *u8 = (sys_mmap(9)) as *u8
91 e_w1252_ascii[0] = 0x5a as u8
92 let o_w1252_ascii: *u8 = (sys_mmap(64)) as *u8
93 let n_w1252_ascii: i64 = nx_charset_to_utf8(i_w1252_ascii, 1, 2, o_w1252_ascii, 64)
94 if cs_eq(o_w1252_ascii, n_w1252_ascii, e_w1252_ascii, 1) != 1 { return 107 }
95
96 let i_utf8_pass: *u8 = (sys_mmap(10)) as *u8
97 i_utf8_pass[0] = 0xc3 as u8
98 i_utf8_pass[1] = 0xa9 as u8
99 let e_utf8_pass: *u8 = (sys_mmap(10)) as *u8
100 e_utf8_pass[0] = 0xc3 as u8
101 e_utf8_pass[1] = 0xa9 as u8
102 let o_utf8_pass: *u8 = (sys_mmap(64)) as *u8
103 let n_utf8_pass: i64 = nx_charset_to_utf8(i_utf8_pass, 2, 0, o_utf8_pass, 64)
104 if cs_eq(o_utf8_pass, n_utf8_pass, e_utf8_pass, 2) != 1 { return 108 }
105
106 let c_det_utf8: *u8 = (sys_mmap(32)) as *u8
107 c_det_utf8[0] = 0x74 as u8
108 c_det_utf8[1] = 0x65 as u8
109 c_det_utf8[2] = 0x78 as u8
110 c_det_utf8[3] = 0x74 as u8
111 c_det_utf8[4] = 0x2f as u8
112 c_det_utf8[5] = 0x68 as u8
113 c_det_utf8[6] = 0x74 as u8
114 c_det_utf8[7] = 0x6d as u8
115 c_det_utf8[8] = 0x6c as u8
116 c_det_utf8[9] = 0x3b as u8
117 c_det_utf8[10] = 0x20 as u8
118 c_det_utf8[11] = 0x63 as u8
119 c_det_utf8[12] = 0x68 as u8
120 c_det_utf8[13] = 0x61 as u8
121 c_det_utf8[14] = 0x72 as u8
122 c_det_utf8[15] = 0x73 as u8
123 c_det_utf8[16] = 0x65 as u8
124 c_det_utf8[17] = 0x74 as u8
125 c_det_utf8[18] = 0x3d as u8
126 c_det_utf8[19] = 0x75 as u8
127 c_det_utf8[20] = 0x74 as u8
128 c_det_utf8[21] = 0x66 as u8
129 c_det_utf8[22] = 0x2d as u8
130 c_det_utf8[23] = 0x38 as u8
131 if nx_charset_from_content_type(c_det_utf8, 24) != 0 { return 200 }
132
133 let c_det_lat1: *u8 = (sys_mmap(36)) as *u8
134 c_det_lat1[0] = 0x74 as u8
135 c_det_lat1[1] = 0x65 as u8
136 c_det_lat1[2] = 0x78 as u8
137 c_det_lat1[3] = 0x74 as u8
138 c_det_lat1[4] = 0x2f as u8
139 c_det_lat1[5] = 0x68 as u8
140 c_det_lat1[6] = 0x74 as u8
141 c_det_lat1[7] = 0x6d as u8
142 c_det_lat1[8] = 0x6c as u8
143 c_det_lat1[9] = 0x3b as u8
144 c_det_lat1[10] = 0x63 as u8
145 c_det_lat1[11] = 0x68 as u8
146 c_det_lat1[12] = 0x61 as u8
147 c_det_lat1[13] = 0x72 as u8
148 c_det_lat1[14] = 0x73 as u8
149 c_det_lat1[15] = 0x65 as u8
150 c_det_lat1[16] = 0x74 as u8
151 c_det_lat1[17] = 0x3d as u8
152 c_det_lat1[18] = 0x69 as u8
153 c_det_lat1[19] = 0x73 as u8
154 c_det_lat1[20] = 0x6f as u8
155 c_det_lat1[21] = 0x2d as u8
156 c_det_lat1[22] = 0x38 as u8
157 c_det_lat1[23] = 0x38 as u8
158 c_det_lat1[24] = 0x35 as u8
159 c_det_lat1[25] = 0x39 as u8
160 c_det_lat1[26] = 0x2d as u8
161 c_det_lat1[27] = 0x31 as u8
162 if nx_charset_from_content_type(c_det_lat1, 28) != 1 { return 201 }
163
164 let c_det_w1252: *u8 = (sys_mmap(39)) as *u8
165 c_det_w1252[0] = 0x74 as u8
166 c_det_w1252[1] = 0x65 as u8
167 c_det_w1252[2] = 0x78 as u8
168 c_det_w1252[3] = 0x74 as u8
169 c_det_w1252[4] = 0x2f as u8
170 c_det_w1252[5] = 0x68 as u8
171 c_det_w1252[6] = 0x74 as u8
172 c_det_w1252[7] = 0x6d as u8
173 c_det_w1252[8] = 0x6c as u8
174 c_det_w1252[9] = 0x3b as u8
175 c_det_w1252[10] = 0x20 as u8
176 c_det_w1252[11] = 0x63 as u8
177 c_det_w1252[12] = 0x68 as u8
178 c_det_w1252[13] = 0x61 as u8
179 c_det_w1252[14] = 0x72 as u8
180 c_det_w1252[15] = 0x73 as u8
181 c_det_w1252[16] = 0x65 as u8
182 c_det_w1252[17] = 0x74 as u8
183 c_det_w1252[18] = 0x3d as u8
184 c_det_w1252[19] = 0x77 as u8
185 c_det_w1252[20] = 0x69 as u8
186 c_det_w1252[21] = 0x6e as u8
187 c_det_w1252[22] = 0x64 as u8
188 c_det_w1252[23] = 0x6f as u8
189 c_det_w1252[24] = 0x77 as u8
190 c_det_w1252[25] = 0x73 as u8
191 c_det_w1252[26] = 0x2d as u8
192 c_det_w1252[27] = 0x31 as u8
193 c_det_w1252[28] = 0x32 as u8
194 c_det_w1252[29] = 0x35 as u8
195 c_det_w1252[30] = 0x32 as u8
196 if nx_charset_from_content_type(c_det_w1252, 31) != 2 { return 202 }
197
198 let c_det_none: *u8 = (sys_mmap(17)) as *u8
199 c_det_none[0] = 0x74 as u8
200 c_det_none[1] = 0x65 as u8
201 c_det_none[2] = 0x78 as u8
202 c_det_none[3] = 0x74 as u8
203 c_det_none[4] = 0x2f as u8
204 c_det_none[5] = 0x68 as u8
205 c_det_none[6] = 0x74 as u8
206 c_det_none[7] = 0x6d as u8
207 c_det_none[8] = 0x6c as u8
208 if nx_charset_from_content_type(c_det_none, 9) != 0 { return 203 }
209
210 let c_det_latin1: *u8 = (sys_mmap(33)) as *u8
211 c_det_latin1[0] = 0x74 as u8
212 c_det_latin1[1] = 0x65 as u8
213 c_det_latin1[2] = 0x78 as u8
214 c_det_latin1[3] = 0x74 as u8
215 c_det_latin1[4] = 0x2f as u8
216 c_det_latin1[5] = 0x68 as u8
217 c_det_latin1[6] = 0x74 as u8
218 c_det_latin1[7] = 0x6d as u8
219 c_det_latin1[8] = 0x6c as u8
220 c_det_latin1[9] = 0x3b as u8
221 c_det_latin1[10] = 0x20 as u8
222 c_det_latin1[11] = 0x63 as u8
223 c_det_latin1[12] = 0x68 as u8
224 c_det_latin1[13] = 0x61 as u8
225 c_det_latin1[14] = 0x72 as u8
226 c_det_latin1[15] = 0x73 as u8
227 c_det_latin1[16] = 0x65 as u8
228 c_det_latin1[17] = 0x74 as u8
229 c_det_latin1[18] = 0x3d as u8
230 c_det_latin1[19] = 0x4c as u8
231 c_det_latin1[20] = 0x61 as u8
232 c_det_latin1[21] = 0x74 as u8
233 c_det_latin1[22] = 0x69 as u8
234 c_det_latin1[23] = 0x6e as u8
235 c_det_latin1[24] = 0x31 as u8
236 if nx_charset_from_content_type(c_det_latin1, 25) != 1 { return 204 }
237
238 let c_det_cp1252: *u8 = (sys_mmap(41)) as *u8
239 c_det_cp1252[0] = 0x61 as u8
240 c_det_cp1252[1] = 0x70 as u8
241 c_det_cp1252[2] = 0x70 as u8
242 c_det_cp1252[3] = 0x6c as u8
243 c_det_cp1252[4] = 0x69 as u8
244 c_det_cp1252[5] = 0x63 as u8
245 c_det_cp1252[6] = 0x61 as u8
246 c_det_cp1252[7] = 0x74 as u8
247 c_det_cp1252[8] = 0x69 as u8
248 c_det_cp1252[9] = 0x6f as u8
249 c_det_cp1252[10] = 0x6e as u8
250 c_det_cp1252[11] = 0x2f as u8
251 c_det_cp1252[12] = 0x78 as u8
252 c_det_cp1252[13] = 0x68 as u8
253 c_det_cp1252[14] = 0x74 as u8
254 c_det_cp1252[15] = 0x6d as u8
255 c_det_cp1252[16] = 0x6c as u8
256 c_det_cp1252[17] = 0x3b as u8
257 c_det_cp1252[18] = 0x20 as u8
258 c_det_cp1252[19] = 0x63 as u8
259 c_det_cp1252[20] = 0x68 as u8
260 c_det_cp1252[21] = 0x61 as u8
261 c_det_cp1252[22] = 0x72 as u8
262 c_det_cp1252[23] = 0x73 as u8
263 c_det_cp1252[24] = 0x65 as u8
264 c_det_cp1252[25] = 0x74 as u8
265 c_det_cp1252[26] = 0x3d as u8
266 c_det_cp1252[27] = 0x63 as u8
267 c_det_cp1252[28] = 0x70 as u8
268 c_det_cp1252[29] = 0x31 as u8
269 c_det_cp1252[30] = 0x32 as u8
270 c_det_cp1252[31] = 0x35 as u8
271 c_det_cp1252[32] = 0x32 as u8
272 if nx_charset_from_content_type(c_det_cp1252, 33) != 2 { return 205 }
273
274 // sniff sn_hdr_lat1 -> 1
275 let b_sn_hdr_lat1: *u8 = (sys_mmap(37)) as *u8
276 b_sn_hdr_lat1[0] = 0x74 as u8
277 b_sn_hdr_lat1[1] = 0x65 as u8
278 b_sn_hdr_lat1[2] = 0x78 as u8
279 b_sn_hdr_lat1[3] = 0x74 as u8
280 b_sn_hdr_lat1[4] = 0x2f as u8
281 b_sn_hdr_lat1[5] = 0x68 as u8
282 b_sn_hdr_lat1[6] = 0x74 as u8
283 b_sn_hdr_lat1[7] = 0x6d as u8
284 b_sn_hdr_lat1[8] = 0x6c as u8
285 b_sn_hdr_lat1[9] = 0x3b as u8
286 b_sn_hdr_lat1[10] = 0x20 as u8
287 b_sn_hdr_lat1[11] = 0x63 as u8
288 b_sn_hdr_lat1[12] = 0x68 as u8
289 b_sn_hdr_lat1[13] = 0x61 as u8
290 b_sn_hdr_lat1[14] = 0x72 as u8
291 b_sn_hdr_lat1[15] = 0x73 as u8
292 b_sn_hdr_lat1[16] = 0x65 as u8
293 b_sn_hdr_lat1[17] = 0x74 as u8
294 b_sn_hdr_lat1[18] = 0x3d as u8
295 b_sn_hdr_lat1[19] = 0x69 as u8
296 b_sn_hdr_lat1[20] = 0x73 as u8
297 b_sn_hdr_lat1[21] = 0x6f as u8
298 b_sn_hdr_lat1[22] = 0x2d as u8
299 b_sn_hdr_lat1[23] = 0x38 as u8
300 b_sn_hdr_lat1[24] = 0x38 as u8
301 b_sn_hdr_lat1[25] = 0x35 as u8
302 b_sn_hdr_lat1[26] = 0x39 as u8
303 b_sn_hdr_lat1[27] = 0x2d as u8
304 b_sn_hdr_lat1[28] = 0x31 as u8
305 if nx_charset_sniff(b_sn_hdr_lat1, 29) != 1 { return 300 }
306
307 // sniff sn_hdr_none -> -1
308 let b_sn_hdr_none: *u8 = (sys_mmap(17)) as *u8
309 b_sn_hdr_none[0] = 0x74 as u8
310 b_sn_hdr_none[1] = 0x65 as u8
311 b_sn_hdr_none[2] = 0x78 as u8
312 b_sn_hdr_none[3] = 0x74 as u8
313 b_sn_hdr_none[4] = 0x2f as u8
314 b_sn_hdr_none[5] = 0x68 as u8
315 b_sn_hdr_none[6] = 0x74 as u8
316 b_sn_hdr_none[7] = 0x6d as u8
317 b_sn_hdr_none[8] = 0x6c as u8
318 if nx_charset_sniff(b_sn_hdr_none, 9) != -1 { return 301 }
319
320 // sniff sn_meta_short -> 1
321 let b_sn_meta_short: *u8 = (sys_mmap(35)) as *u8
322 b_sn_meta_short[0] = 0x3c as u8
323 b_sn_meta_short[1] = 0x6d as u8
324 b_sn_meta_short[2] = 0x65 as u8
325 b_sn_meta_short[3] = 0x74 as u8
326 b_sn_meta_short[4] = 0x61 as u8
327 b_sn_meta_short[5] = 0x20 as u8
328 b_sn_meta_short[6] = 0x63 as u8
329 b_sn_meta_short[7] = 0x68 as u8
330 b_sn_meta_short[8] = 0x61 as u8
331 b_sn_meta_short[9] = 0x72 as u8
332 b_sn_meta_short[10] = 0x73 as u8
333 b_sn_meta_short[11] = 0x65 as u8
334 b_sn_meta_short[12] = 0x74 as u8
335 b_sn_meta_short[13] = 0x3d as u8
336 b_sn_meta_short[14] = 0x22 as u8
337 b_sn_meta_short[15] = 0x69 as u8
338 b_sn_meta_short[16] = 0x73 as u8
339 b_sn_meta_short[17] = 0x6f as u8
340 b_sn_meta_short[18] = 0x2d as u8
341 b_sn_meta_short[19] = 0x38 as u8
342 b_sn_meta_short[20] = 0x38 as u8
343 b_sn_meta_short[21] = 0x35 as u8
344 b_sn_meta_short[22] = 0x39 as u8
345 b_sn_meta_short[23] = 0x2d as u8
346 b_sn_meta_short[24] = 0x31 as u8
347 b_sn_meta_short[25] = 0x22 as u8
348 b_sn_meta_short[26] = 0x3e as u8
349 if nx_charset_sniff(b_sn_meta_short, 27) != 1 { return 302 }
350
351 // sniff sn_meta_utf8 -> 0
352 let b_sn_meta_utf8: *u8 = (sys_mmap(28)) as *u8
353 b_sn_meta_utf8[0] = 0x3c as u8
354 b_sn_meta_utf8[1] = 0x6d as u8
355 b_sn_meta_utf8[2] = 0x65 as u8
356 b_sn_meta_utf8[3] = 0x74 as u8
357 b_sn_meta_utf8[4] = 0x61 as u8
358 b_sn_meta_utf8[5] = 0x20 as u8
359 b_sn_meta_utf8[6] = 0x63 as u8
360 b_sn_meta_utf8[7] = 0x68 as u8
361 b_sn_meta_utf8[8] = 0x61 as u8
362 b_sn_meta_utf8[9] = 0x72 as u8
363 b_sn_meta_utf8[10] = 0x73 as u8
364 b_sn_meta_utf8[11] = 0x65 as u8
365 b_sn_meta_utf8[12] = 0x74 as u8
366 b_sn_meta_utf8[13] = 0x3d as u8
367 b_sn_meta_utf8[14] = 0x75 as u8
368 b_sn_meta_utf8[15] = 0x74 as u8
369 b_sn_meta_utf8[16] = 0x66 as u8
370 b_sn_meta_utf8[17] = 0x2d as u8
371 b_sn_meta_utf8[18] = 0x38 as u8
372 b_sn_meta_utf8[19] = 0x3e as u8
373 if nx_charset_sniff(b_sn_meta_utf8, 20) != 0 { return 303 }
374
375 // sniff sn_meta_heq -> 2
376 let b_sn_meta_heq: *u8 = (sys_mmap(95)) as *u8
377 b_sn_meta_heq[0] = 0x3c as u8
378 b_sn_meta_heq[1] = 0x68 as u8
379 b_sn_meta_heq[2] = 0x65 as u8
380 b_sn_meta_heq[3] = 0x61 as u8
381 b_sn_meta_heq[4] = 0x64 as u8
382 b_sn_meta_heq[5] = 0x3e as u8
383 b_sn_meta_heq[6] = 0x3c as u8
384 b_sn_meta_heq[7] = 0x6d as u8
385 b_sn_meta_heq[8] = 0x65 as u8
386 b_sn_meta_heq[9] = 0x74 as u8
387 b_sn_meta_heq[10] = 0x61 as u8
388 b_sn_meta_heq[11] = 0x20 as u8
389 b_sn_meta_heq[12] = 0x68 as u8
390 b_sn_meta_heq[13] = 0x74 as u8
391 b_sn_meta_heq[14] = 0x74 as u8
392 b_sn_meta_heq[15] = 0x70 as u8
393 b_sn_meta_heq[16] = 0x2d as u8
394 b_sn_meta_heq[17] = 0x65 as u8
395 b_sn_meta_heq[18] = 0x71 as u8
396 b_sn_meta_heq[19] = 0x75 as u8
397 b_sn_meta_heq[20] = 0x69 as u8
398 b_sn_meta_heq[21] = 0x76 as u8
399 b_sn_meta_heq[22] = 0x3d as u8
400 b_sn_meta_heq[23] = 0x22 as u8
401 b_sn_meta_heq[24] = 0x43 as u8
402 b_sn_meta_heq[25] = 0x6f as u8
403 b_sn_meta_heq[26] = 0x6e as u8
404 b_sn_meta_heq[27] = 0x74 as u8
405 b_sn_meta_heq[28] = 0x65 as u8
406 b_sn_meta_heq[29] = 0x6e as u8
407 b_sn_meta_heq[30] = 0x74 as u8
408 b_sn_meta_heq[31] = 0x2d as u8
409 b_sn_meta_heq[32] = 0x54 as u8
410 b_sn_meta_heq[33] = 0x79 as u8
411 b_sn_meta_heq[34] = 0x70 as u8
412 b_sn_meta_heq[35] = 0x65 as u8
413 b_sn_meta_heq[36] = 0x22 as u8
414 b_sn_meta_heq[37] = 0x20 as u8
415 b_sn_meta_heq[38] = 0x63 as u8
416 b_sn_meta_heq[39] = 0x6f as u8
417 b_sn_meta_heq[40] = 0x6e as u8
418 b_sn_meta_heq[41] = 0x74 as u8
419 b_sn_meta_heq[42] = 0x65 as u8
420 b_sn_meta_heq[43] = 0x6e as u8
421 b_sn_meta_heq[44] = 0x74 as u8
422 b_sn_meta_heq[45] = 0x3d as u8
423 b_sn_meta_heq[46] = 0x22 as u8
424 b_sn_meta_heq[47] = 0x74 as u8
425 b_sn_meta_heq[48] = 0x65 as u8
426 b_sn_meta_heq[49] = 0x78 as u8
427 b_sn_meta_heq[50] = 0x74 as u8
428 b_sn_meta_heq[51] = 0x2f as u8
429 b_sn_meta_heq[52] = 0x68 as u8
430 b_sn_meta_heq[53] = 0x74 as u8
431 b_sn_meta_heq[54] = 0x6d as u8
432 b_sn_meta_heq[55] = 0x6c as u8
433 b_sn_meta_heq[56] = 0x3b as u8
434 b_sn_meta_heq[57] = 0x20 as u8
435 b_sn_meta_heq[58] = 0x63 as u8
436 b_sn_meta_heq[59] = 0x68 as u8
437 b_sn_meta_heq[60] = 0x61 as u8
438 b_sn_meta_heq[61] = 0x72 as u8
439 b_sn_meta_heq[62] = 0x73 as u8
440 b_sn_meta_heq[63] = 0x65 as u8
441 b_sn_meta_heq[64] = 0x74 as u8
442 b_sn_meta_heq[65] = 0x3d as u8
443 b_sn_meta_heq[66] = 0x77 as u8
444 b_sn_meta_heq[67] = 0x69 as u8
445 b_sn_meta_heq[68] = 0x6e as u8
446 b_sn_meta_heq[69] = 0x64 as u8
447 b_sn_meta_heq[70] = 0x6f as u8
448 b_sn_meta_heq[71] = 0x77 as u8
449 b_sn_meta_heq[72] = 0x73 as u8
450 b_sn_meta_heq[73] = 0x2d as u8
451 b_sn_meta_heq[74] = 0x31 as u8
452 b_sn_meta_heq[75] = 0x32 as u8
453 b_sn_meta_heq[76] = 0x35 as u8
454 b_sn_meta_heq[77] = 0x32 as u8
455 b_sn_meta_heq[78] = 0x22 as u8
456 b_sn_meta_heq[79] = 0x3e as u8
457 b_sn_meta_heq[80] = 0x3c as u8
458 b_sn_meta_heq[81] = 0x2f as u8
459 b_sn_meta_heq[82] = 0x68 as u8
460 b_sn_meta_heq[83] = 0x65 as u8
461 b_sn_meta_heq[84] = 0x61 as u8
462 b_sn_meta_heq[85] = 0x64 as u8
463 b_sn_meta_heq[86] = 0x3e as u8
464 if nx_charset_sniff(b_sn_meta_heq, 87) != 2 { return 304 }
465
466 // sniff sn_nocs -> -1
467 let b_sn_nocs: *u8 = (sys_mmap(44)) as *u8
468 b_sn_nocs[0] = 0x3c as u8
469 b_sn_nocs[1] = 0x68 as u8
470 b_sn_nocs[2] = 0x74 as u8
471 b_sn_nocs[3] = 0x6d as u8
472 b_sn_nocs[4] = 0x6c as u8
473 b_sn_nocs[5] = 0x3e as u8
474 b_sn_nocs[6] = 0x3c as u8
475 b_sn_nocs[7] = 0x62 as u8
476 b_sn_nocs[8] = 0x6f as u8
477 b_sn_nocs[9] = 0x64 as u8
478 b_sn_nocs[10] = 0x79 as u8
479 b_sn_nocs[11] = 0x3e as u8
480 b_sn_nocs[12] = 0x70 as u8
481 b_sn_nocs[13] = 0x6c as u8
482 b_sn_nocs[14] = 0x61 as u8
483 b_sn_nocs[15] = 0x69 as u8
484 b_sn_nocs[16] = 0x6e as u8
485 b_sn_nocs[17] = 0x20 as u8
486 b_sn_nocs[18] = 0x74 as u8
487 b_sn_nocs[19] = 0x65 as u8
488 b_sn_nocs[20] = 0x78 as u8
489 b_sn_nocs[21] = 0x74 as u8
490 b_sn_nocs[22] = 0x3c as u8
491 b_sn_nocs[23] = 0x2f as u8
492 b_sn_nocs[24] = 0x62 as u8
493 b_sn_nocs[25] = 0x6f as u8
494 b_sn_nocs[26] = 0x64 as u8
495 b_sn_nocs[27] = 0x79 as u8
496 b_sn_nocs[28] = 0x3e as u8
497 b_sn_nocs[29] = 0x3c as u8
498 b_sn_nocs[30] = 0x2f as u8
499 b_sn_nocs[31] = 0x68 as u8
500 b_sn_nocs[32] = 0x74 as u8
501 b_sn_nocs[33] = 0x6d as u8
502 b_sn_nocs[34] = 0x6c as u8
503 b_sn_nocs[35] = 0x3e as u8
504 if nx_charset_sniff(b_sn_nocs, 36) != -1 { return 305 }
505
506 // INTEGRATION: <meta charset=windows-1252> page (no HTTP header):
507 // sniff(body) -> WIN1252 -> transcode -> render -> clean UTF-8
508 let mh: *u8 = (sys_mmap(54)) as *u8
509 mh[0] = 0x3c as u8
510 mh[1] = 0x6d as u8
511 mh[2] = 0x65 as u8
512 mh[3] = 0x74 as u8
513 mh[4] = 0x61 as u8
514 mh[5] = 0x20 as u8
515 mh[6] = 0x63 as u8
516 mh[7] = 0x68 as u8
517 mh[8] = 0x61 as u8
518 mh[9] = 0x72 as u8
519 mh[10] = 0x73 as u8
520 mh[11] = 0x65 as u8
521 mh[12] = 0x74 as u8
522 mh[13] = 0x3d as u8
523 mh[14] = 0x22 as u8
524 mh[15] = 0x77 as u8
525 mh[16] = 0x69 as u8
526 mh[17] = 0x6e as u8
527 mh[18] = 0x64 as u8
528 mh[19] = 0x6f as u8
529 mh[20] = 0x77 as u8
530 mh[21] = 0x73 as u8
531 mh[22] = 0x2d as u8
532 mh[23] = 0x31 as u8
533 mh[24] = 0x32 as u8
534 mh[25] = 0x35 as u8
535 mh[26] = 0x32 as u8
536 mh[27] = 0x22 as u8
537 mh[28] = 0x3e as u8
538 mh[29] = 0x3c as u8
539 mh[30] = 0x70 as u8
540 mh[31] = 0x3e as u8
541 mh[32] = 0x43 as u8
542 mh[33] = 0x61 as u8
543 mh[34] = 0x66 as u8
544 mh[35] = 0xe9 as u8
545 mh[36] = 0x20 as u8
546 mh[37] = 0x97 as u8
547 mh[38] = 0x20 as u8
548 mh[39] = 0x66 as u8
549 mh[40] = 0x69 as u8
550 mh[41] = 0x6e as u8
551 mh[42] = 0x3c as u8
552 mh[43] = 0x2f as u8
553 mh[44] = 0x70 as u8
554 mh[45] = 0x3e as u8
555 let mcs: i64 = nx_charset_sniff(mh, 46)
556 if mcs != 2 { return 400 }
557 let mtb: *u8 = (sys_mmap(256)) as *u8
558 let mtl: i64 = nx_charset_to_utf8(mh, 46, mcs, mtb, 256)
559 if mtl <= 0 { return 401 }
560 let mrb: *u8 = (sys_mmap(256)) as *u8
561 let mrl: i64 = nx_html_to_text(mtb, mtl, mrb, 256)
562 let mex: *u8 = (sys_mmap(22)) as *u8
563 mex[0] = 0x43 as u8
564 mex[1] = 0x61 as u8
565 mex[2] = 0x66 as u8
566 mex[3] = 0xc3 as u8
567 mex[4] = 0xa9 as u8
568 mex[5] = 0x20 as u8
569 mex[6] = 0xe2 as u8
570 mex[7] = 0x80 as u8
571 mex[8] = 0x94 as u8
572 mex[9] = 0x20 as u8
573 mex[10] = 0x66 as u8
574 mex[11] = 0x69 as u8
575 mex[12] = 0x6e as u8
576 mex[13] = 0x0a as u8
577 if cs_eq(mrb, mrl, mex, 14) != 1 { return 402 }
578
579 return 0
580}