]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/testdata/conversion.txt
ICU-8.11.4.tar.gz
[apple/icu.git] / icuSources / test / testdata / conversion.txt
CommitLineData
374ca955
A
1//*******************************************************************************
2//
fd0068a8 3// Copyright (C) 2003-2006,2008 International Business Machines
374ca955
A
4// Corporation and others. All Rights Reserved.
5//
6// file name: conversion.txt
7// encoding: US-ASCII
8// tab size: 8 (not used)
9// indentation:4
10//
11// created on: 2003jul15
12// created by: Markus W. Scherer
13//
14// ICU resource bundle source file with test data for data-driven conversion tests.
15//
16//*******************************************************************************
17
73c04bcf 18conversion:table(nofallback) {
374ca955
A
19 Info {
20 Description { "Test data for conversion" }
21 LongDescription {
22 "Test data for data-driven conversion tests in icu/source/test/intltest/convtest.cpp\n"
23 "Run intltest conversion\n"
24
25 "Charset names starting with '*' are for testdata names.\n"
26
27 "ICU callbacks are specified as strings with pairs of characters, each optional.\n"
28 "Callback function - '?'=Sub '0'=Skip '.'=Stop '&'=Escape\n"
29 "Callback option - a letter is passed in directly as const char * see ucnv_err.h\n"
30 "Empty string: Sub callback with NULL option\n"
31
73c04bcf 32 "In order to specify a charset substitution character (for ucnv_setSubstChars()),\n"
374ca955
A
33 "add a NUL (U+0000) to the callback string followed by the subchar bytes as Latin-1\n"
34 "characters. For example, for a Sub callback with no option and a subchar of FC FC,\n"
35 "use the string \"?\x00\xFC\xFC\"\n"
36
73c04bcf
A
37 "In order to specify a substitution string (for ucnv_setSubstString()),\n"
38 "add an '=' to the callback string followed by the substitution string.\n"
39 "For example, for a Sub callback with no option and a substitution string\n"
40 "of \"ab\", use the string \"?=ab\"\n"
41
374ca955
A
42 "fallbacks: per-direction boolean, currently only for fromUnicode; see Jitterbug 2401\n"
43
44 "errorCode: (empty)==zero | invalid | illegal | truncated | illesc | unsuppesc\n"
45 }
46 }
47 TestData {
48 toUnicode {
49 Headers { "charset", "bytes", "unicode", "offsets", "flush", "fallbacks", "errorCode", "callback", "invalidChars" }
50 Cases {
fd0068a8
A
51 // Test ticket 5691: consistent illegal sequences
52 // The following test cases are for illegal character byte sequences.
53 //
54 // Unfortunately, we cannot use the Shift-JIS examples from the ticket
55 // comments because our Shift-JIS table is Windows-compatible and
56 // therefore has no illegal single bytes. Same for GBK.
57 // Instead, we use the stricter GB 18030 also for 2-byte examples.
58 // The byte sequences are generally slightly different from the ticket
59 // comment, simply using assigned characters rather than just
60 // theoretically valid sequences.
61 {
62 "gb18030",
63 :bin{ 618140813c81ff7a },
64 "a\u4e02\\x81<\\x81\\xFFz",
65 :intvector{ 0,1,3,3,3,3,4,5,5,5,5,5,5,5,5,7 },
66 :int{1}, :int{0}, "", "&C", :bin{""}
67 }
68 {
69 "EUC-JP",
70 :bin{ 618fb0a98fb03c8f3cb0a97a },
71 "a\u4e28\\x8F\\xB0<\\x8F<\u9022z",
72 :intvector{ 0,1,4,4,4,4,5,5,5,5,6,7,7,7,7,8,9,11 },
73 :int{1}, :int{0}, "", "&C", :bin{""}
74 }
75 {
76 "gb18030",
77 :bin{ 618130fc318130fc8181303c3e813cfc817a },
78 "a\u05ed\\x810\u9f07\\x810<>\\x81<\u9f07z",
79 :intvector{ 0,1,5,5,5,5,6,7,9,9,9,9,10,11,12,13,13,13,13,14,15,17 },
80 :int{1}, :int{0}, "", "&C", :bin{""}
81 }
82 {
83 "UTF-8",
84 :bin{ 61f1808182f180813cf18081fff180ff3cf1ff3c3e7a },
85 "a\U00040042\\xF1\\x80\\x81<\\xF1\\x80\\x81\\xFF\\xF1\\x80\\xFF<\\xF1\\xFF<>z",
86 :intvector{ 0,1,1,5,5,5,5,5,5,5,5,5,5,5,5,8,9,9,9,9,9,9,9,9,9,9,9,9,12,12,12,12,13,13,13,13,13,13,13,13,15,15,15,15,16,17,17,17,17,18,18,18,18,19,20,21 },
87 :int{1}, :int{0}, "", "&C", :bin{""}
88 }
89 {
90 "ISO-2022-JP",
91 :bin{ 1b24424141af4142affe41431b2842 },
92 "\u758f\\xAF\u758e\\xAF\\xFE\u790e",
93 :intvector{ 3,5,5,5,5,6,8,8,8,8,8,8,8,8,10 },
94 :int{1}, :int{0}, "", "&C", :bin{""}
95 }
96 {
97 "ibm-25546",
98 :bin{ 411b242943420e4141af4142affe41430f5a },
99 "AB\uc88b\\xAF\uc88c\\xAF\\xFE\uc88dZ",
100 :intvector{ 0,5,7,9,9,9,9,10,12,12,12,12,12,12,12,12,14,17 },
101 :int{1}, :int{0}, "", "&C", :bin{""}
102 }
103 {
104 "ISO-2022-KR",
105 :bin{ 411b242943420e4141af4142affe41430f5a },
106 "AB\uc88b\\xAF\uc88c\\xAF\\xFE\uc88dZ",
107 :intvector{ 0,5,7,9,9,9,9,10,12,12,12,12,12,12,12,12,14,17 },
108 :int{1}, :int{0}, "", "&C", :bin{""}
109 }
110 {
111 "ISO-2022-CN",
112 :bin{ 411b242941420e4141af4142affe41430f5a },
113 "AB\u4eae\\xAF\u8c05\\xAF\\xFE\u64a9Z",
114 :intvector{ 0,5,7,9,9,9,9,10,12,12,12,12,12,12,12,12,14,17 },
115 :int{1}, :int{0}, "", "&C", :bin{""}
116 }
117 {
118 "HZ",
119 :bin{ 417e7b4141af4142affe41437e7d5a },
120 "A\u4eae\\xAF\u8c05\\xAF\\xFE\u64a9Z",
121 :intvector{ 0,3,5,5,5,5,6,8,8,8,8,8,8,8,8,10,14 },
122 :int{1}, :int{0}, "", "&C", :bin{""}
123 }
124 // Test ticket 5691: consistent illegal sequences
125 // The following test cases are for illegal escape/designator/shift sequences.
126 //
127 // ISO-2022-JP and -CN with illegal escape sequences.
128 {
129 "ISO-2022-JP",
130 :bin{ 611b24201b244241411b283f1b28427a },
131 "a\\x1B$ \u758f\\x1B\u2538z",
132 :intvector{ 0,1,1,1,1,2,3,7,9,9,9,9,10,15 },
133 :int{1}, :int{0}, "", "&C", :bin{""}
134 }
135 {
136 "ISO-2022-CN",
137 :bin{ 611b2429201b2429410e41410f7a },
138 "a\\x1B$) \u4eaez",
139 :intvector{ 0,1,1,1,1,2,3,4,10,13 },
140 :int{1}, :int{0}, "", "&C", :bin{""}
141 }
142 // Test ticket 5691: ISO-2022-JP-2 with illegal single-shift SS2 and SS3 sequences.
143 // The first ESC N comes before its designator sequence, the last sequence is ESC+space.
144 {
145 "ISO-2022-JP-2",
146 :bin{ 4e1b4e4e1b2e414e1b4e4e4e1b204e },
147 "N\\x1BNNN\xceN\\x1B N",
148 :intvector{ 0,1,1,1,1,2,3,7,10,11,12,12,12,12,13,14 },
149 :int{1}, :int{0}, "", "&C", :bin{""}
150 }
151 {
152 "ISO-2022-CN-EXT",
153 :bin{ 4e1b4e4e1b242a484e1b4e4e4e4e1b204e },
154 "N\\x1BNNN\u8f0eN\\x1B N",
155 :intvector{ 0,1,1,1,1,2,3,8,11,13,14,14,14,14,15,16 },
156 :int{1}, :int{0}, "", "&C", :bin{""}
157 }
158 {
159 "ISO-2022-CN-EXT",
160 :bin{ 4f1b4f4f1b242b494f1b4f4f4f4f1b204f },
161 "O\\x1BOOO\u492bO\\x1B O",
162 :intvector{ 0,1,1,1,1,2,3,8,11,13,14,14,14,14,15,16 },
163 :int{1}, :int{0}, "", "&C", :bin{""}
164 }
165 // Test ticket 5691: HZ with illegal tilde sequences.
166 {
167 "HZ",
168 :bin{ 417e20427e21437e80447e7b41417e207e41427e7f41437e7d5a },
169 "A\\x7E B\\x7E!C\\x7E\\x80D\u4eae\\x7E\\x20\\x7E\u8c05\\x7E\\x7F\u64a9Z",
170 :intvector{ 0,1,1,1,1,2,3,4,4,4,4,5,6,7,7,7,7,7,7,7,7,9, // SBCS
171 12,14,14,14,14,14,14,14,14,16,16,16,16,17,19,19,19,19,19,19,19,19,21, // DBCS
172 25 }, // SBCS
173 :int{1}, :int{0}, "", "&C", :bin{""}
174 }
175 // Test ticket 5691: Example from Peter Edberg.
176 {
177 "ISO-2022-JP",
178 :bin{ 1b244230212f7e742630801b284a621b2458631b2842648061 },
179 "\u4e9c\ufffd\u7199\ufffdb\ufffd$Xcd\ufffda",
180 :intvector{ 3,5,7,9,14,15,16,17,18,22,23,24 },
181 :int{1}, :int{0}, "", "?", :bin{""}
182 }
183 // test that HZ limits its byte values to lead bytes 21..7d and trail bytes 21..7e
184 {
185 "HZ",
186 :bin{ 7e7b21212120217e217f772100007e217e7e7d207e7e807e0a2b },
187 "\u3000\ufffd\u3013\ufffd\u9ccc\ufffd\ufffd\u3013 ~\ufffd+",
188 :intvector{ 2,4,6,8,10,12,14,15,19,20,22,25 },
189 :int{1}, :int{1}, "", "?", :bin{""}
190 }
191 // improve coverage of ISO-2022-JP converter with hardcoded JIS X 0201 and
192 // using the Shift-JIS table for JIS X 0208 (ticket #5797)
193 {
194 "ISO-2022-JP",
195 :bin{ 1b284a7d7e801b2442306c20217f7e21202160217f22202225227f5f211b2842 },
196 "}\u203e\ufffd\u4e00\ufffd\ufffd\ufffd\ufffd\xf7\ufffd\ufffd\u25b2\ufffd\u6f3e",
197 :intvector{ 3,4,5,9,11,12,14,16,17,19,21,23,25,27 },
198 :int{1}, :int{1}, "", "?", :bin{""}
199 }
374ca955
A
200 // improve coverage of unrolled loops in ucnvmbcs.c/ucnv_MBCSSingleToBMPWithOffsets()
201 {
202 "ISO-8859-3",
203 :bin{ 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627 },
204 "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\x22#$%&'",
205 :intvector{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39 },
206 :int{1}, :int{0}, "", "?", :bin{""}
207 }
208 // test that ISO-2022-JP encodes ASCII as itself
209 {
210 "ISO-2022-JP",
211 :bin{ 3f4041424344454647 },
212 "?@ABCDEFG",
213 :intvector{ 0,1,2,3,4,5,6,7,8 },
214 :int{1}, :int{1}, "", "?", :bin{""}
215 }
216 // test that ISO-2022-CN encodes ASCII as itself
217 {
218 "ISO-2022-CN",
219 :bin{ 3f4041424344454647 },
220 "?@ABCDEFG",
221 :intvector{ 0,1,2,3,4,5,6,7,8 },
222 :int{1}, :int{1}, "", "?", :bin{""}
223 }
224
225 // ISO-2022-KR
226
227 // truncated, partial escape sequence
228 {
229 "ibm-25546",
230 :bin{ 1b }, "", :intvector{},
231 :int{1}, :int{1}, "truncated", ".", :bin{ 1b }
232 }
233 {
234 "ibm-25546",
235 :bin{ 1b24 }, "", :intvector{},
236 :int{1}, :int{1}, "truncated", ".", :bin{ 1b24 }
237 }
238 {
239 "ibm-25546",
240 :bin{ 1b2429 }, "", :intvector{},
241 :int{1}, :int{1}, "truncated", ".", :bin{ 1b2429 }
242 }
243 // complete escape sequence but nothing else
244 {
245 "ibm-25546",
246 :bin{ 1b242943 }, "", :intvector{},
247 :int{1}, :int{1}, "", ".", :bin{""}
248 }
249 {
250 "ibm-25546",
251 :bin{ 1b2429430e }, "", :intvector{},
252 :int{1}, :int{1}, "", ".", :bin{""}
253 }
254 // escape plus ASCII character
255 {
256 "ibm-25546",
257 :bin{ 1b24294341 }, "A", :intvector{ 4 },
258 :int{1}, :int{1}, "", ".", :bin{""}
259 }
260 // escape plus incomplete DBCS character
261 {
262 "ibm-25546",
263 :bin{ 1b2429430e41 }, "", :intvector{},
264 :int{1}, :int{1}, "truncated", ".", :bin{ 41 }
265 }
266 // all complete with DBCS character
267 {
268 "ibm-25546",
269 :bin{ 1b2429430e4141 }, "\uc88b", :intvector{ 5 },
270 :int{1}, :int{1}, "", ".", :bin{""}
271 }
272 // more complicated example
273 {
274 "ibm-25546",
275 :bin{ 411b242943420e4141affe0f43 },
276 "AB\uc88b%XAF%XFEC",
277 :intvector{ 0, 5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 12 },
278 :int{1}, :int{1}, "", "&", :bin{""}
279 }
280
281 // truncated, partial escape sequence
282 {
283 "ISO-2022-KR",
284 :bin{ 1b }, "", :intvector{},
285 :int{1}, :int{1}, "truncated", ".", :bin{ 1b }
286 }
287 {
288 "ISO-2022-KR",
289 :bin{ 1b24 }, "", :intvector{},
290 :int{1}, :int{1}, "truncated", ".", :bin{ 1b24 }
291 }
292 {
293 "ISO-2022-KR",
294 :bin{ 1b2429 }, "", :intvector{},
295 :int{1}, :int{1}, "truncated", ".", :bin{ 1b2429 }
296 }
297 // complete escape sequence but nothing else
298 {
299 "ISO-2022-KR",
300 :bin{ 1b242943 }, "", :intvector{},
301 :int{1}, :int{1}, "", ".", :bin{""}
302 }
303 {
304 "ISO-2022-KR",
305 :bin{ 1b2429430e }, "", :intvector{},
306 :int{1}, :int{1}, "", ".", :bin{""}
307 }
308 // escape plus ASCII character
309 {
310 "ISO-2022-KR",
311 :bin{ 1b24294341 }, "A", :intvector{ 4 },
312 :int{1}, :int{1}, "", ".", :bin{""}
313 }
314 // escape plus incomplete DBCS character
315 {
316 "ISO-2022-KR",
317 :bin{ 1b2429430e41 }, "", :intvector{},
318 :int{1}, :int{1}, "truncated", ".", :bin{ 41 }
319 }
320 // all complete with DBCS character
321 {
322 "ISO-2022-KR",
323 :bin{ 1b2429430e4141 }, "\uc88b", :intvector{ 5 },
324 :int{1}, :int{1}, "", ".", :bin{""}
325 }
326 // more complicated example
327 {
328 "ISO-2022-KR",
329 :bin{ 411b242943420e4141affe0f43 },
330 "AB\uc88b%XAF%XFEC",
331 :intvector{ 0, 5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 12 },
332 :int{1}, :int{1}, "", "&", :bin{""}
333 }
d5d484b0
A
334 // empty segment (using substitution and stop)
335 {
336 "ISO-2022-KR",
337 :bin{ 1b242943610e0f620d0a },
338 "a\uFFFDb\u000D\u000A",
339 :intvector{ 4, 6, 7, 8, 9 },
340 :int{1}, :int{1}, "", "?", :bin{""}
341 }
342 {
343 "ISO-2022-KR",
344 :bin{ 1b242943610e0f620d0a },
345 "a",
346 :intvector{ 4 },
347 :int{1}, :int{1}, "illesc", ".", :bin{"0f"}
348 }
374ca955
A
349
350 // ISO-2022-JP
351
352 // truncated, partial escape sequence
353 {
354 "ISO-2022-JP",
355 :bin{ 1b }, "", :intvector{},
356 :int{1}, :int{1}, "truncated", ".", :bin{ 1b }
357 }
358 {
359 "ISO-2022-JP-2",
360 :bin{ 1b24 }, "", :intvector{},
361 :int{1}, :int{1}, "truncated", ".", :bin{ 1b24 }
362 }
363 // complete escape sequence but nothing else
364 {
365 "ISO-2022-JP-2",
366 :bin{ 1b2442 }, "", :intvector{},
367 :int{1}, :int{1}, "", ".", :bin{""}
368 }
369 // escape plus incomplete DBCS character
370 {
371 "ISO-2022-JP-2",
372 :bin{ 1b244241 }, "", :intvector{},
373 :int{1}, :int{1}, "truncated", ".", :bin{ 41 }
374 }
375 // all complete with DBCS character
376 {
377 "ISO-2022-JP-2",
378 :bin{ 1b24424141 }, "\u758f", :intvector{ 3 },
379 :int{1}, :int{1}, "", ".", :bin{""}
380 }
381 // test the G2 designator & SS2 shift
382 {
383 "ISO-2022-JP-2",
384 :bin{ 431b2e46461b244241411b4e4e353f }, "CF\u758f\u039e\u7591", :intvector{ 0, 4, 8, 12, 13 },
385 :int{1}, :int{1}, "", ".", :bin{""}
386 }
387 // JIS7 with Katakana
388 {
389 "JIS7",
390 :bin{ 41420e41420f4142 }, "AB\uff81\uff82AB", :intvector{ 0, 1, 3, 4, 6, 7 },
391 :int{1}, :int{1}, "", ".", :bin{""}
392 }
393 // JIS8 with Katakana
394 {
395 "JIS8",
396 :bin{ 41c15c1b284a5cc242 }, "A\uff81\\\xa5\uff82B", :intvector{ 0, 1, 2, 6, 7, 8 },
397 :int{1}, :int{1}, "", ".", :bin{""}
398 }
d5d484b0
A
399 // empty segment (using substitution and stop)
400 {
401 "ISO-2022-JP",
402 :bin{ 61621b24421b284263640d0a },
403 "ab\uFFFDcd\u000D\u000A",
404 :intvector{ 0, 1, 5, 8, 9, 10, 11 },
405 :int{1}, :int{1}, "", "?", :bin{""}
406 }
407 {
408 "ISO-2022-JP",
409 :bin{ 61621b24421b284263640d0a },
410 "ab",
411 :intvector{ 0, 1 },
412 :int{1}, :int{1}, "illesc", ".", :bin{"1b2842"}
413 }
374ca955
A
414
415 // ISO-2022-CN
416
417 // truncated, partial escape sequence
418 {
419 "ISO_2022,locale=zh,version=1",
420 :bin{ 1b }, "", :intvector{},
421 :int{1}, :int{1}, "truncated", ".", :bin{ 1b }
422 }
423 {
424 "ISO_2022,locale=zh,version=1",
425 :bin{ 1b24 }, "", :intvector{},
426 :int{1}, :int{1}, "truncated", ".", :bin{ 1b24 }
427 }
428 {
429 "ISO_2022,locale=zh,version=1",
430 :bin{ 1b2429 }, "", :intvector{},
431 :int{1}, :int{1}, "truncated", ".", :bin{ 1b2429 }
432 }
433 // complete escape sequence but nothing else
434 {
435 "ISO_2022,locale=zh,version=1",
436 :bin{ 1b242941 }, "", :intvector{},
437 :int{1}, :int{1}, "", ".", :bin{""}
438 }
439 {
440 "ISO_2022,locale=zh,version=1",
441 :bin{ 1b2429410e }, "", :intvector{},
442 :int{1}, :int{1}, "", ".", :bin{""}
443 }
444 // escape plus ASCII character
445 {
446 "ISO_2022,locale=zh,version=1",
447 :bin{ 1b24294141 }, "\x41", :intvector{ 4 },
448 :int{1}, :int{1}, "", ".", :bin{""}
449 }
450 // escape plus incomplete DBCS character
451 {
452 "ISO_2022,locale=zh,version=1",
453 :bin{ 1b2429410e41 }, "", :intvector{},
454 :int{1}, :int{1}, "truncated", ".", :bin{ 41 }
455 }
456 // all complete with DBCS character
457 {
458 "ISO_2022,locale=zh,version=1",
459 :bin{ 1b2429410e4141 }, "\u4eae", :intvector{ 5 },
460 :int{1}, :int{1}, "", ".", :bin{""}
461 }
462 // ISO-2022-CN-EXT with all subcharsets and shifts and with supplementary code points
463 {
464 "ISO-2022-CN-EXT",
465 :bin{ 1b2429411b242a480e41411b2429457e7c1b4e70341b242b4d1b2429477c341b4f664c2421 },
466 "\u4eae\u9f82\u56cd\u56cc\U0002a6d6\x30",
467 :intvector{ 9, 15, 19, 29, 33, 33, 35 },
468 :int{1}, :int{1}, "", ".", :bin{""}
469 }
470
471 // illegal and unsupported escape sequences
472 // SS2 without designator: illegal
473 {
474 "ISO-2022-CN-EXT",
475 :bin{ 411b4e2121 }, "\x41", :intvector{ 0 },
fd0068a8 476 :int{1}, :int{1}, "illesc", ".", :bin{ 1b }
374ca955
A
477 }
478 // G3 designator: recognized, but not supported for -CN (only for -CN-EXT)
479 {
480 "ISO-2022-CN",
481 :bin{ 411b242b491b4f2121 }, "\x41", :intvector{ 0 },
482 :int{1}, :int{1}, "unsuppesc", ".", :bin{ 1b242b49 }
483 }
d5d484b0
A
484 // empty segment 1 (using substitution and stop)
485 {
486 "ISO-2022-CN",
487 :bin{ 611b242941620e0f1b242a481b4e6a65630d0a },
488 "ab\uFFFD\u994Cc\u000D\u000A",
489 :intvector{ 0, 5, 7, 14, 16, 17, 18 },
490 :int{1}, :int{1}, "", "?", :bin{""}
491 }
492 {
493 "ISO-2022-CN",
494 :bin{ 611b242941620e0f1b242a481b4e6a65630d0a },
495 "ab",
496 :intvector{ 0, 5 },
497 :int{1}, :int{1}, "illesc", ".", :bin{"0f"}
498 }
499 // empty segment 2 (using substitution and stop)
500 {
501 "ISO-2022-CN",
502 :bin{ 611b242941620e1b24294768640f630d0a },
503 "ab\uFFFD\u5F70c\u000D\u000A",
504 :intvector{ 0, 5, 7, 11, 14, 15, 16 },
505 :int{1}, :int{1}, "", "?", :bin{""}
506 }
507 {
508 "ISO-2022-CN",
509 :bin{ 611b242941620e1b24294768640f630d0a },
510 "ab",
511 :intvector{ 0, 5 },
512 :int{1}, :int{1}, "illesc", ".", :bin{"1b242947"}
513 }
374ca955
A
514
515 // ISO-2022 SBCS
516 // [U_ENABLE_GENERIC_ISO_2022]
517 // The _generic_ ISO-2022 converter is disabled starting 2003-dec-03 (ICU 2.8).
518 // For details see the icu mailing list from 2003-dec-01 and the ucnv2022.c file.
519 // Language-specific variants of ISO-2022 continue to be available as listed below.
520 //{
521 // "ISO_2022",
522 // :bin{ 0008090a0d1a1c1f203f415c7d7e7f },
523 // "\x00\x08\t\n\r\x1a\x1c\x1f ?A\\}~\x7f",
524 // :intvector{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 },
525 // :int{1}, :int{1}, "", ".", :bin{""}
526 //}
527
d5d484b0
A
528 // HZ-GB-2312
529
530 // empty segment (using substitution and stop)
531 {
532 "HZ-GB-2312",
533 :bin{ 61627e7b7e7d6364 },
534 "ab\uFFFDcd",
535 :intvector{ 0, 1, 4, 6, 7 },
536 :int{1}, :int{1}, "", "?", :bin{""}
537 }
538 {
539 "HZ-GB-2312",
540 :bin{ 61627e7b7e7d63640d0a },
541 "ab",
542 :intvector{ 0, 1 },
543 :int{1}, :int{1}, "illesc", ".", :bin{"7e7d"}
544 }
545
374ca955
A
546 // DBCS-only extensions
547 {
548 "ibm-970",
549 :bin{ 617eece9b2eb },
550 "\x61\x7e\u4e00\ub000",
551 :intvector{ 0, 1, 2, 4 },
552 :int{1}, :int{1}, "", "?", :bin{""}
553 }
554
555 {
556 "ibm-971",
557 :bin{ 617eece9b2eb },
558 "\ufffd\u4e00\ub000",
559 :intvector{ 0, 2, 4 },
560 :int{1}, :int{1}, "", "?", :bin{""}
561 }
562
563 {
564 "ibm-16684",
565 :bin{ 430e4395ecc1404042e1 },
566 "\ufffd\u30C8\u30C8\u309A\u3000\u20ac",
567 :intvector{ 0, 2, 4, 4, 6, 8 },
568 :int{1}, :int{0}, "", "?", :bin{""}
569 }
570
571 {
572 "ibm-1399",
573 :bin{ 430e4395ecc140400fe1 },
574 "\uff62\u30C8\u30C8\u309A\u3000\u20ac",
575 :intvector{ 0, 2, 4, 4, 6, 9 },
576 :int{1}, :int{0}, "", "?", :bin{""}
577 }
578
579 // extensions
580 {
581 "ibm-1390",
582 :bin{ 430e4395ecc1 },
583 "\uff63\u30C8\u30C8\u309A",
584 :intvector{ 0, 2, 4, 4 },
585 :int{1}, :int{0}, "", "?", :bin{""}
586 }
587
588 {
589 "ibm-16684",
590 :bin{ ececec8bec8cec8d4386ecb5ecb6ecb7 },
591 "\ufffd\u31f6\u31f7\u31f8\u30ab\u304b\u309a\u304d\u309a\u304f\u309a",
592 :intvector{ 0, 2, 4, 6, 8, 10, 10, 12, 12, 14, 14 },
593 :int{1}, :int{0}, "", "?", :bin{""}
594 }
595
596 {
597 "ibm-1390",
598 :bin{ 43860eececec8bec8cec8d4386ecb5ecb6ecb7ecc10fec },
599 "\uff63\uff76\ufffd\u31f6\u31f7\u31f8\u30ab\u304b\u309a\u304d\u309a\u304f\u309a\u30C8\u309A\x1a",
600 :intvector{ 0, 1, 3, 5, 7, 9, 11, 13, 13, 15, 15, 17, 17, 19, 19, 22 },
601 :int{1}, :int{0}, "", "?", :bin{""}
602 }
603
604 {
605 "*test3",
606 :bin{ 00050601020b0701020a01020c },
607 "\u20ac\x05\x06\x0b\U00101234\U00023456\ufffd",
608 :intvector{ 0, 1, 2, 3, 6, 6, 7, 7, 10 },
609 :int{1}, :int{0}, "", "?", :bin{""}
610 }
611
612 // normal conversions
613 {
614 "UTF-16LE",
615 :bin{ 310000d801dc00d902dc320000d8330001dc3400 },
616 "1\U00010001\U000500022\ufffd3\ufffd4",
617 :intvector{ 0, 2, 2, 6, 6, 10, 12, 14, 16, 18 },
618 :int{1}, :int{0}, "", "?", :bin{""}
619 }
620 { "UTF-16LE", :bin{ 00 }, "", :intvector{}, :int{1}, :int{0}, "truncated", ".", :bin{ 00 } }
621 { "UTF-16LE", :bin{ 00d800 }, "", :intvector{}, :int{1}, :int{0}, "truncated", ".", :bin{ 00d800 } }
622
623 {
624 "UTF-16BE",
625 :bin{ 0031d800dc01d900dc020032d8000033dc010034 },
626 "1\U00010001\U000500022\ufffd3\ufffd4",
627 :intvector{ 0, 2, 2, 6, 6, 10, 12, 14, 16, 18 },
628 :int{1}, :int{0}, "", "?", :bin{""}
629 }
630 { "UTF-16BE", :bin{ 00 }, "", :intvector{}, :int{1}, :int{0}, "truncated", ".", :bin{ 00 } }
631 { "UTF-16BE", :bin{ d800dc }, "", :intvector{}, :int{1}, :int{0}, "truncated", ".", :bin{ d800dc } }
632
633 // e4b8 is a partial sequence
634 { "UTF-8", :bin{ 31e4ba8ce4b8 }, "1\u4e8c", :intvector{ 0, 1 }, :int{1}, :int{0}, "truncated", ".", :bin{ e4b8 } }
635 { "UTF-8", :bin{ 31e4ba8ce4b8 }, "1\u4e8c\ufffd", :intvector{ 0, 1, 4 }, :int{1}, :int{0}, "", "?", :bin{""} }
636
637 // LMBCS with escape callback (1292a0 is unassigned)
638 {
639 "LMBCS",
640 :bin{ 12c9501292a01292a1 },
641 "\u4e2e%X12%X92%XA0\ue5c4",
642 :intvector{ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 6 },
643 :int{1}, :int{0}, "", "&", :bin{""}
644 }
645
646 // IMAP-mailbox-name with SUB
647 // a<DEL> a&AB~ a&AB\x0c a&AB- a&AB. a&.
648 {
649 "IMAP-mailbox-name",
650 :bin{ 617f612641427e612641420c612641422d612641422e61262e },
651 "a\ufffda\ufffda\ufffda\ufffda\ufffda\ufffd",
652 :intvector{ 0, 1, 2, 4, 7, 9, 12, 14, 17, 19, 22, 23 },
653 :int{1}, :int{0}, "", "?", :bin{""}
654 }
655
656 // using testdata_test1.cnv
657 { "*test1", :bin{ 000506070809 }, "\u20ac\x05\x06\U00101234\ufffd\ufffd", :intvector{ 0, 1, 2, 3, 3, 4, 5 }, :int{1}, :int{0}, "", "", :bin{""} }
658
659 // surrogates in CESU-8
660 { "CESU-8", :bin{ eda080eda081edb081 }, "\ud800\U00010401", :intvector{ 0, 3, 6 }, :int{1}, :int{0}, "", "", :bin{""} }
661 // e080 is a partial sequence
662 { "UTF-8", :bin{ 31ffe4ba8ce08061 }, "1\ufffd\u4e8c\ufffda", :intvector{ 0, 1, 2, 5, 7 }, :int{0}, :int{0}, "", "", :bin{ e080 } }
663 // fbbfbfbfbf exceedes U+10ffff
664 { "UTF-8", :bin{ 31fbbfbfbfbf61 }, "1\ufffda", :intvector{ 0, 1, 6 }, :int{0}, :int{0}, "", "", :bin{ fbbfbfbfbf } }
665
666 // lead byte a2 without trail byte
667 { "ibm-1363", :bin{ a2aea2 }, "\u00a1", :intvector{ 0 }, :int{1}, :int{0}, "truncated", ".", :bin{ a2 } }
668 { "ibm-1363", :bin{ a2aea2 }, "\u00a1\u001a", :intvector{ 0, 2 }, :int{1}, :int{0}, "", "?", :bin{""} }
669
670 // simple sample, no error handling
671 { "UTF-8", :bin{ 61F48FBFBF }, "a\U0010FFFF", :intvector{ 0, 1, 1 }, :int{1}, :int{0}, "", "", :bin{""} }
672 }
673 }
674
675 // --------------------------------------------------------------------- ***
676
677 fromUnicode {
678 Headers { "charset", "unicode", "bytes", "offsets", "flush", "fallbacks", "errorCode", "callback", "invalidUChars" }
679 Cases {
73c04bcf
A
680 {
681 "SCSU",
682 "1\U00010001\u0085\U000500022\ud8003\udc014\ue001",
683 :bin{ 310be0008102050fd900dc02e7320efffd330efffd34186881 },
684 :intvector{ 0,1,1,1,1,3,3,4,4,4,4,4,6,6,7,7,7,8,9,9,9,10,11,11,11 },
685 :int{1}, :int{0}, "", "?", ""
686 }
687 // Test substitution strings.
688 {
689 "windows-1252", // stateless MBCS with WriteSub(), should internally set char *
690 "a\ufdd0c",
691 :bin{ 61402421402463 },
692 :intvector{ 0,1,1,1,1,1,2 },
693 :int{1}, :int{0}, "", "?=@$!@$", ""
694 }
695 {
696 "ibm-930", // stateful MBCS
697 "a\ufdd0\u4e00\ufdd0e",
698 :bin{ 620e4bce0f400e45414bce0f4066 },
699 :intvector{ 0,1,1,1,1,1,2,2,2,3,3,3,3,4 },
700 :int{1}, :int{0}, "", "?=\u4e01 ", ""
701 }
702 {
703 "iso-2022-jp",
704 "a\x1bc", // Unicode ESC must not occur as a character
705 :bin{ 6163 },
706 :intvector{ 0,2 },
707 :int{1}, :int{0}, "", "?=", "" // empty substitution string
708 }
709 {
710 "iso-2022-cn",
711 "a\x1bc", // Unicode ESC must not occur as a character
712 :bin{ 61202063 },
713 :intvector{ 0,1,1,2 },
714 :int{1}, :int{0}, "", "?= ", ""
715 }
716 {
717 "iso-2022-cn",
718 "a\x1bc", // Unicode ESC must not occur as a character
719 :bin{ 611b2429410e523b0f2063 },
720 :intvector{ 0,1,1,1,1,1,1,1,1,1,2 },
721 :int{1}, :int{0}, "", "?=\u4e00 ", ""
722 }
723 {
724 "us-ascii",
725 "a\x85c",
726 :bin{ 61402421402463 },
727 :intvector{ 0,1,1,1,1,1,2 },
728 :int{1}, :int{0}, "", "?=@$!@$", ""
729 }
730 // ISO 2022-CN: test a single-byte subchar, j5171
731 {
732 "iso-2022-cn",
733 "a\x1bc", // Unicode ESC must not occur as a character
734 :bin{ 612163 },
735 :intvector{ 0,1,2 },
736 :int{1}, :int{0}, "", "?\x00\x21", ""
737 }
738 // UTF-16/32: do not output a BOM if there is no data at all
739 {
740 "UTF-16",
741 "",
742 :bin{ "" },
743 :intvector{ },
744 :int{1}, :int{1}, "", "?", ""
745 }
746 {
747 "UTF-32",
748 "",
749 :bin{ "" },
750 :intvector{ },
751 :int{1}, :int{1}, "", "?", ""
752 }
753
754 // do not convert SO/SI/ESC
755 {
756 "iso-2022-jp",
757 "A\x0eB\x0f\x09\x1bC",
758 :bin{ 411a421a091a43 },
759 :intvector{ 0,1,2,3,4,5,6 },
760 :int{1}, :int{1}, "", "?", ""
761 }
762 {
763 "iso-2022-cn",
764 "A\x0eB\x0f\x09\x1bC",
765 :bin{ 411a421a091a43 },
766 :intvector{ 0,1,2,3,4,5,6 },
767 :int{1}, :int{1}, "", "?", ""
768 }
769 {
770 "iso-2022-kr",
771 "A\x0eB\x0f\x09\x1bC",
772 :bin{ 1b242943411a421a091a43 },
773 :intvector{ -1,-1,-1,-1,0,1,2,3,4,5,6 },
774 :int{1}, :int{1}, "", "?", ""
775 }
776 {
777 "ibm-25546",
778 "A\x0eB\x0f\x09\x1bC",
779 :bin{ 1b242943411a421a091a43 },
780 :intvector{ -1,-1,-1,-1,0,1,2,3,4,5,6 },
781 :int{1}, :int{1}, "", "?", ""
782 }
783
784 // test ISO 8859-1/7 vs. JIS X 0201
785 {
786 "ISO-2022-JP-2",
787 "?@A\u00e4\u03b1\u203EB",
788 :bin{ 3f40411B2E411B4E641B2E461B4E611B284A7E421B2842 },
789 :intvector{ 0,1,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,6,6,6,6 },
790 :int{1}, :int{1}, "", "?", ""
791 }
792
374ca955
A
793 // Improve ucnv_ext.c code coverage:
794 // There will be a partial match up to the lead surrogate of U+603ff
795 // which then results in one more unit in the prefetch buffer
796 // than the match length when converting one code unit at a time.
797 // See ucnv_extContinueMatchFromU() comment
798 // "the match did not use all of preFromU[] - keep the rest for replay"
799 {
800 "*test3",
801 "\U00101234\U00101234\U00050005\U000603ff",
802 :bin{ 07070001020e05ff },
803 :intvector{ 0, 2, 2, 2, 2, 2, 2, 6 },
804 :int{1}, :int{0}, "", "?", ""
805 }
806
807 // test that ISO-2022-JP encodes ASCII as itself
808 {
809 "ISO-2022-JP",
810 "?@ABCDEFG",
811 :bin{ 3f4041424344454647 },
812 :intvector{ 0,1,2,3,4,5,6,7,8 },
813 :int{1}, :int{1}, "", "?", ""
814 }
815 // test that ISO-2022-CN encodes ASCII as itself
816 {
817 "ISO-2022-CN",
818 "?@ABCDEFG",
819 :bin{ 3f4041424344454647 },
820 :intvector{ 0,1,2,3,4,5,6,7,8 },
821 :int{1}, :int{1}, "", "?", ""
822 }
823
824 // moved from cintltst /tsconv/nccbtst/TestSkipCallBack
825 {
826 "iso-2022-jp",
827 "\u3000\xe9\u3001",
828 :bin{ 1b2442212121221b2842 },
829 :intvector{ 0,0,0,0,0,2,2,2,2,2 },
830 :int{1}, :int{1}, "", "0", ""
831 }
832 // moved from cintltst /tsconv/nccbtst/TestSubCallBack
833 {
834 "iso-2022-jp",
835 "A\xe9B\xe9\u3000",
836 :bin{ 411a421a1b244221211b2842 },
837 :intvector{ 0,1,2,3,4,4,4,4,4,4,4,4 },
838 :int{1}, :int{1}, "", "?", ""
839 }
840 // moved from cintltst /tsconv/nccbtst/TestSubWithValueCallBack
841 {
842 "iso-2022-jp",
843 "A\xe9B\xe9\u3000",
844 :bin{ 41255530304539422555303045391b244221211b2842 },
845 :intvector{ 0,1,1,1,1,1,1,2,3,3,3,3,3,3,4,4,4,4,4,4,4,4 },
846 :int{1}, :int{1}, "", "&", ""
847 }
848 {
849 "iso-2022-cn",
850 "\u4e00\u3712\u4e01",
851 :bin{ 1b2429410e523b0f2555333731320e36210f },
852 :intvector{ 0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2 },
853 :int{1}, :int{1}, "", "&", ""
854 }
855 {
856 "iso-2022-cn",
857 "A\u3712\u4e00",
858 :bin{ 412555333731321b2429410e523b0f },
859 :intvector{ 0,1,1,1,1,1,1,2,2,2,2,2,2,2,2 },
860 :int{1}, :int{1}, "", "&", ""
861 }
862 {
863 "iso-2022-cn",
864 "\u3000\u3712\u3001",
865 :bin{ 1b2429410e21210f2555333731320e21220f },
866 :intvector{ 0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2 },
867 :int{1}, :int{1}, "", "&", ""
868 }
869
870 // moved from cintltst /tsconv/nucnvtst/TestJIS
871 {
872 "JIS",
873 "\uFF81\uFF82\u30EC\u30ED\u30EE\u30EF\uFF93\uFF94\uFF95\uFF96\uFF97\uFF98",
874 :bin{ 1b244225412544256c256d256e256F25622564256625682569256a1b2842 },
875 :intvector{ 0,0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,11,11,11 },
876 :int{1}, :int{1}, "", "?", ""
877 }
878 {
879 "JIS7",
880 "\uFF81\uFF82\u30EC\u30ED\u30EE\u30EF\uFF93\uFF94\uFF95\uFF96\uFF97\uFF98",
881 :bin{ 0e41420f1b2442256c256d256e256F0e5354555657580f1b2842 },
882 :intvector{ 0,0,1,2,2,2,2,2,2,3,3,4,4,5,5,6,6,7,8,9,10,11,11,11,11,11 },
883 :int{1}, :int{1}, "", "?", ""
884 }
885 {
886 "JIS8",
887 "\uFF81\uFF82\u30EC\u30ED\u30EE\u30EF\uFF93\uFF94\uFF95\uFF96\uFF97\uFF98",
888 :bin{ C1C21b2442256c256d256e256F1b284AD3D4D5D6D7D81b2842 },
889 :intvector{ 0,1,2,2,2,2,2,3,3,4,4,5,5,6,6,6,6,7,8,9,10,11,11,11,11 },
890 :int{1}, :int{1}, "", "?", ""
891 }
892
893 // moved from cintltst /tsconv/ncnvtst/TestErrorBehaviour
894 {
895 "iso-2022-jp",
896 "\u3000\x50\udc01\u3001",
897 :bin{ 1B244221211B2842501A1B24422122 },
898 :intvector{ 0,0,0,0,0,1,1,1,1,2,3,3,3,3,3 },
899 :int{0}, :int{1}, "", "?", "\udc01"
900 }
901 {
902 "iso-2022-jp",
903 "\u3000\x50\udc01\u3001",
904 :bin{ 1B244221211B2842501A1B244221221b2842 },
905 :intvector{ 0,0,0,0,0,1,1,1,1,2,3,3,3,3,3,3,3,3 },
906 :int{1}, :int{1}, "", "?", ""
907 }
908 {
909 "iso-2022-kr",
910 "\x61\u4e00\udc01\u4e00",
911 :bin{ 1b242943610e6c690f1a0e6c69 },
912 :intvector{ -1,-1,-1,-1,0,1,1,1,2,2,3,3,3 },
913 :int{0}, :int{1}, "", "?", "\udc01"
914 }
915 {
916 "iso-2022-kr",
917 "\x61\u4e00\udc01\u4e00",
918 :bin{ 1b242943610e6c690f1a0e6c690f },
919 :intvector{ -1,-1,-1,-1,0,1,1,1,2,2,3,3,3,3 },
920 :int{1}, :int{1}, "", "?", ""
921 }
922
923 // ISO-2022-KR
924 {
925 "ibm-25546",
926 "AB\uc88b\U00050005\uacccC",
927 :bin{ 1b24294341420e41410f7b552b35303030357d0e306a0f43 },
928 :intvector{ -1,-1,-1,-1,0,1,2,2,2,3,3,3,3,3,3,3,3,3,3,5,5,5,6,6 },
929 :int{1}, :int{1}, "", "&U", ""
930 }
931 {
932 "ibm-25546",
933 "AB\uc88b\U00050005\uacccC",
934 :bin{ 1b24294341420e41410f1a0e306a0f43 },
935 :intvector{ -1,-1,-1,-1,0,1,2,2,2,3,3,5,5,5,6,6 },
936 :int{1}, :int{1}, "", "?\x00\x1a", ""
937 }
938 {
939 "ibm-25546",
940 "AB\uc88b\U00050005\uacccC",
941 :bin{ 1b24294341420e41412f7e306a0f43 },
942 :intvector{ -1,-1,-1,-1,0,1,2,2,2,3,3,5,5,6,6 },
943 :int{1}, :int{1}, "", "?", ""
944 }
945 {
946 "ibm-25546",
947 "AB\uc88b\U00050005\uaccc",
948 :bin{ 1b24294341420e41412f7e306a0f },
949 :intvector{ -1,-1,-1,-1,0,1,2,2,2,3,3,5,5,5 },
950 :int{1}, :int{1}, "", "?", ""
951 }
952 {
953 "ISO-2022-KR",
954 "AB\uc88b\U00050005\uacccC",
955 :bin{ 1b24294341420e41410f7b552b35303030357d0e306a0f43 },
956 :intvector{ -1,-1,-1,-1,0,1,2,2,2,3,3,3,3,3,3,3,3,3,3,5,5,5,6,6 },
957 :int{1}, :int{1}, "", "&U", ""
958 }
959 {
960 "ISO-2022-KR",
961 "AB\uc88b\U00050005\uacccC",
962 :bin{ 1b24294341420e41410f1a0e306a0f43 },
963 :intvector{ -1,-1,-1,-1,0,1,2,2,2,3,3,5,5,5,6,6 },
964 :int{1}, :int{1}, "", "?", ""
965 }
966 {
967 "ISO-2022-KR",
968 "AB\uc88b\U00050005\uacccC",
969 :bin{ 1b24294341420e41412f7e306a0f43 },
970 :intvector{ -1,-1,-1,-1,0,1,2,2,2,3,3,5,5,6,6 },
971 :int{1}, :int{1}, "", "?\x00\x2f\x7e", ""
972 }
973 {
974 "ISO-2022-KR",
975 "AB\uc88b\U00050005\uaccc",
976 :bin{ 1b24294341420e41412f7e306a0f },
977 :intvector{ -1,-1,-1,-1,0,1,2,2,2,3,3,5,5,5 },
978 :int{1}, :int{1}, "", "?\x00\x2f\x7e", ""
979 }
980
981 // ISO-2022-JP-2 with G2 designator & SS2 shift
982 {
983 "ISO-2022-JP-2",
984 "CF\u758f\u038f\u7591",
985 :bin{ 43461b244241411b2e461b4e3f353f1b2842 },
986 :intvector{ 0,1,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4 },
987 :int{1}, :int{1}, "", ".", ""
988 }
989 // JIS7 with Katakana
990 {
991 "JIS7",
992 "AB\uff81\uff82AB",
993 :bin{ 41420e41420f4142 },
994 :intvector{ 0,1,2,2,3,4,4,5 },
995 :int{1}, :int{1}, "", ".", ""
996 }
997 // JIS7 with shift to ASCII at the very end
998 {
999 "JIS7",
1000 "AB\uff81\uff82",
1001 :bin{ 41420e41420f },
1002 :intvector{ 0,1,2,2,3,3 },
1003 :int{1}, :int{1}, "", ".", ""
1004 }
1005 // JIS8 with Katakana
1006 {
1007 "JIS8",
1008 "A\uff81\\\xa5\uff82B",
1009 :bin{ 41c15c1b284a5cc2421b2842 },
1010 :intvector{ 0,1,2,3,3,3,3,4,5,5,5,5 },
1011 :int{1}, :int{1}, "", ".", ""
1012 }
1013
1014 // ISO-2022-CN-EXT with all subcharsets and shifts and with supplementary code points
1015 {
1016 "ISO-2022-CN-EXT",
1017 "\u4eae\u9f82\u56cd\u56cc\U0002a6d6\x30",
1018 :bin{ 1b2429410e41411b2429457e7c1b242a481b4e70341b2429477c341b242b4d1b4f664c0f30 },
1019 :intvector{ 0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,4,4,6,6 },
1020 :int{1}, :int{1}, "", ".", ""
1021 }
1022 // ISO-2022-CN-EXT with shift to ASCII at the very end
1023 {
1024 "ISO-2022-CN-EXT",
1025 "\u4eae\u9f82\u56cd\u56cc\U0002a6d6",
1026 :bin{ 1b2429410e41411b2429457e7c1b242a481b4e70341b2429477c341b242b4d1b4f664c0f },
1027 :intvector{ 0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4 },
1028 :int{1}, :int{1}, "", ".", ""
1029 }
1030 // ISO-2022-CN-EXT without flush so do not shift to ASCII at the very end
1031 {
1032 "ISO-2022-CN-EXT",
1033 "\u4eae\u9f82\u56cd\u56cc\U0002a6d6",
1034 :bin{ 1b2429410e41411b2429457e7c1b242a481b4e70341b2429477c341b242b4d1b4f664c },
1035 :intvector{ 0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,4,4 },
1036 :int{0}, :int{1}, "", ".", ""
1037 }
1038
1039 // windows-936 vs. ibm-1386
1040 {
1041 "ibm-1386",
1042 "\x1a\u20ac\u5555\x80\x81\U00055555",
1043 :bin{ 7fa2e3dffb7f7fa1a1 },
1044 :intvector{ 0, 1, 1, 2, 2, 3, 4, 5, 5 },
1045 :int{1}, :int{1}, "", "?", ""
1046 }
1047 {
1048 "windows-936",
1049 "\x1a\u20ac\u5555\x80\x81\U00055555",
1050 :bin{ 1a80dffb3f3f3f },
1051 :intvector{ 0, 1, 2, 2, 3, 4, 5 },
1052 :int{1}, :int{1}, "", "?", ""
1053 }
1054
1055 // verify that if a conversion table does not have any mapping for U+0000,
1056 // then there will not even be a phantom fallback to 00
1057 {
1058 "ibm-971",
1059 "\x00",
1060 :bin{ affe },
1061 :intvector{ 0, 0 },
1062 :int{1}, :int{1}, "", "?", ""
1063 }
1064
1065 {
1066 "*test4",
1067 "\x00",
1068 :bin{ ff },
1069 :intvector{ 0 },
1070 :int{1}, :int{1}, "", "?", ""
1071 }
1072
1073 // extension in testdata
1074 {
1075 "*test4x",
1076 "\u20ac\x09",
1077 :bin{ 0009 },
1078 :intvector{ 0, 1 },
1079 :int{1}, :int{1}, "", "?", ""
1080 }
1081
1082 // DBCS-only extensions
1083 {
1084 "ibm-970",
1085 "\x61\uffa1\u2015\ub000",
1086 :bin{ 611aa1aab2eb },
1087 :intvector{ 0, 1, 2, 2, 3, 3 },
1088 :int{1}, :int{1}, "", "?", ""
1089 }
1090
1091 {
1092 "ibm-971",
1093 "\x61\uffa1\u2015\ub000",
1094 :bin{ affeaffeaffeb2eb },
1095 :intvector{ 0, 0, 1, 1, 2, 2, 3, 3 },
1096 :int{1}, :int{1}, "", "?", ""
1097 }
1098
1099 {
1100 "ibm-1390,swaplfnl",
1101 "\uff63\u30C8\u30C8\u309A\u3000\x41\u20ac\x0a",
1102 :bin{ 430e4395ecc140400fc1e115 },
1103 :intvector{ 0, 1, 1, 1, 2, 2, 4, 4, 5, 5, 6, 7 },
1104 :int{1}, :int{0}, "", "?", ""
1105 }
1106
1107 {
1108 "ibm-16684",
1109 "\uff63\u30C8\u30C8\u309A\u3000\x41\u20ac\x0a",
1110 :bin{ fefe4395ecc14040fefe42e1fefe },
1111 :intvector{ 0, 0, 1, 1, 2, 2, 4, 4, 5, 5, 6, 6, 7, 7 },
1112 :int{1}, :int{0}, "", "?", ""
1113 }
1114
1115 {
1116 "ibm-1399",
1117 "\uff63\u30C8\u30C8\u309A\u3000\x41\u20ac\x0a",
1118 :bin{ 440e4395ecc140400fc1e125 },
1119 :intvector{ 0, 1, 1, 1, 2, 2, 4, 4, 5, 5, 6, 7 },
1120 :int{1}, :int{0}, "", "?", ""
1121 }
1122
1123 // <subchar1> from |2 mappings
1124 {
1125 "ibm-1390",
1126 "\x0e\x0f\u0901\U00050000\uffe8\uffee",
1127 :bin{ 3f3f0efefefefe0f3f3f },
1128 :intvector{ 0, 1, 2, 2, 2, 3, 3, 5, 5, 6 },
1129 :int{1}, :int{1}, "", "?", ""
1130 }
1131
1132 // <subchar1> from |2 mappings, and also contains a fallback to 00
1133 {
1134 "*test4",
1135 "\u20ac\u20ad\U00050005\U00023456\U0010ffff\x30",
1136 :bin{ 0000e10102030affff },
1137 :intvector{ 0, 1, 2, 4, 4, 4, 4, 6, 8 },
1138 :int{1}, :int{1}, "", "?", ""
1139 }
1140
1141 // setting a <subchar> resets the <subchar1>
1142 {
1143 "*test4",
1144 "\u20ac\u20ad\U00050005\U00023456\U0010ffff\x30",
1145 :bin{ 00000102030f0102030a0102030f0102030f },
1146 :intvector{ 0, 1, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 8, 8, 8, 8 },
1147 :int{1}, :int{1}, "", "?\x00\x01\x02\x03\x0f", ""
1148 }
1149
1150 // fallback to 00 with old single-byte data structure
1151 {
1152 "*test1",
1153 "\u20ac\u20ad\U00101234\U00050000",
1154 :bin{ 000007ff },
1155 :intvector{ 0, 1, 2, 4 },
1156 :int{1}, :int{1}, "", "?", ""
1157 }
1158
1159 // extensions
1160 {
1161 "ibm-1390",
1162 "\u025a\u025a\u0300\u025a\u0301\u025a\u0302\uffe8\U0002a0f9",
1163 :bin{ 0ed896eccaeccbd896ea530f3f0eb7c20f },
1164 :intvector{ 0, 0, 0, 1, 1, 3, 3, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8 },
1165 :int{1}, :int{0}, "", "?", ""
1166 }
1167
1168 {
1169 "*test3",
1170 "\xc4\xc4\xc4\U00101234\xc4\xc4\U00101234\x05",
1171 :bin{ ffffff070501020c },
1172 :intvector{ 0, 1, 2, 3, 5, 5, 5, 5 },
1173 :int{1}, :int{0}, "", "?", ""
1174 }
1175
1176 {
1177 "*test3",
1178 "\U00101234\U00101234\U00050005\U00101234\U00050005\U00060006",
1179 :bin{ 07070001020e05070001020f09 },
1180 :intvector{ 0, 2, 2, 2, 2, 2, 2, 6, 6, 6, 6, 6, 6 },
1181 :int{1}, :int{0}, "", "?", ""
1182 }
1183
1184 // normal conversions
1185 {
1186 "UTF-16LE",
1187 "1\U00010001\U000500022\ud8003\udc014",
1188 :bin{ 310000d801dc00d902dc3200fdff3300fdff3400 },
1189 :intvector{ 0, 0, 1, 1, 1, 1, 3, 3, 3, 3, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 },
1190 :int{1}, :int{0}, "", "?", ""
1191 }
1192 { "UTF-16LE", "\ud800", :bin{""}, :intvector{}, :int{1}, :int{0}, "truncated", ".", "\ud800" }
1193
1194 {
1195 "UTF-16BE",
1196 "1\U00010001\U000500022\ud8003\udc014",
1197 :bin{ 0031d800dc01d900dc020032fffd0033fffd0034 },
1198 :intvector{ 0, 0, 1, 1, 1, 1, 3, 3, 3, 3, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 },
1199 :int{1}, :int{0}, "", "?", ""
1200 }
1201 { "UTF-16BE", "\ud800", :bin{""}, :intvector{}, :int{1}, :int{0}, "truncated", ".", "\ud800" }
1202
73c04bcf
A
1203 {
1204 "SCSU",
1205 "1\U00010001\u00082\ud8003\udc014\ue001",
1206 :bin{ 310be000810108320efffd330efffd34186881 },
1207 :intvector{ 0, 1, 1, 1, 1, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7, 8, 9, 9, 9 },
1208 :int{1}, :int{0}, "", "?", ""
1209 }
1210
374ca955
A
1211 // escape callback
1212 {
1213 "ISCII",
1214 "A\u0901\U00023456\u0902B\U00023456C",
1215 :bin{ 41ef42a1255544383444255544433536a24225554438344425554443353643 },
1216 :intvector{
1217 0,
1218 1,1,1,
1219 2,2,2,2,2,2,
1220 2,2,2,2,2,2,
1221 4,
1222 5,
1223 6,6,6,6,6,6,
1224 6,6,6,6,6,6,
1225 8
1226 },
1227 :int{1}, :int{0}, "", "&", ""
1228 }
1229
1230 // escape callback (hex)
1231 {
1232 "iso-2022-jp",
1233 "\u3000\U00023456\u3001\U00023456B\u901c",
1234 :bin{ 1b244221211b284226237832333435363b1b244221221b284226237832333435363b42262378393031433b },
1235 :intvector{
1236 0,0,0,0,0,
1237 1,1,1,1,1,1,1,1,1,1,1,1,
1238 3,3,3,3,3,
1239 4,4,4,4,4,4,4,4,4,4,4,4,
1240 6,
1241 7,7,7,7,7,7,7,7
1242 },
1243 :int{1}, :int{0}, "", "&X", ""
1244 }
1245
1246 // sub callback
1247 {
1248 "gb18030",
1249 "$\x7f\x80\u01f9\u20ac\u4e00\u9fa6\uffff\U00010000\U0010ffff",
1250 :bin{ 247f81308130a8bfa2e3d2bb82358f338431a43990308130e3329a35 },
1251 :intvector{ 0, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 10, 10, 10, 10 },
1252 :int{1}, :int{0}, "", "?", ""
1253 }
1254
1255 // skip callback
1256 { "ibm-930", "\u6D63\u6D64\u6D65\u6D66", :bin{ 0e5d5f5d63466b0f }, :intvector{ 0, 0, 0, 1, 1, 3, 3, 3 }, :int{1}, :int{0}, "", "0", "" }
1257 { "ibm-930", "\u6D63\u6D64\ud89a\u6D66", :bin{ 0e5d5f5d63466b0f }, :intvector{ 0, 0, 0, 1, 1, 3, 3, 3 }, :int{1}, :int{0}, "", "0", "" }
1258 { "ibm-930", "\u6D63\u6D64\ud89a\u6D66", :bin{ 0e5d5f5d63 }, :intvector{ 0, 0, 0, 1, 1 }, :int{1}, :int{0}, "illegal", "0i", "\ud89a" }
1259
1260 // sub callback for supplementary code point
1261 { "LATIN1", "1\U000104012", :bin{ 311a32 }, :intvector{ 0, 1, 3 }, :int{1}, :int{0}, "", "", "" }
1262 { "ibm-920", "1\U000104012", :bin{ 311a32 }, :intvector{ 0, 1, 3 }, :int{1}, :int{0}, "", "", "" }
1263
1264 // sub callback with AA as subchar
1265 { "ibm-920", "1\U000104012", :bin{ 31AA32 }, :intvector{ 0, 1, 3 }, :int{1}, :int{0}, "", "?\x00\xAA", "" }
1266
1267 // same but not flushing
1268 { "LATIN1", "1\U000104012", :bin{ 311a32 }, :intvector{ 0, 1, 3 }, :int{0}, :int{0}, "", "", "\U00010401" }
1269 { "ibm-920", "1\U000104012", :bin{ 311a32 }, :intvector{ 0, 1, 3 }, :int{0}, :int{0}, "", "", "\U00010401" }
1270
1271 // simple sample, no error handling
1272 { "UTF-8", "a\U0010FFFF", :bin{ 61F48FBFBF }, :intvector{ 0, 1, 1, 1, 1 }, :int{1}, :int{0}, "", "", "" }
1273 }
1274 }
1275
1276 getUnicodeSet {
1277 // charset - will be opened, and ucnv_getUnicodeSet() called on it
1278 // map - set of code points and strings that must be in the returned set
1279 // mapnot - set of code points and strings that must *not* be in the returned set
1280 // which - numeric UConverterUnicodeSet value
1281 Headers { "charset", "map", "mapnot", "which" }
1282 Cases {
73c04bcf
A
1283 // Unicode charsets that do not map surrogate code points
1284 {
1285 "UTF-8",
1286 "[\x00-\ud7ff\ue000-\U0010ffff]",
1287 "[\ud800-\udfff]",
1288 :int{0}
1289 }
1290 {
1291 "UTF-16",
1292 "[\x00-\ud7ff\ue000-\U0010ffff]",
1293 "[\ud800-\udfff]",
1294 :int{0}
1295 }
1296 {
1297 "UTF-16BE",
1298 "[\x00-\ud7ff\ue000-\U0010ffff]",
1299 "[\ud800-\udfff]",
1300 :int{0}
1301 }
1302 {
1303 "UTF-16LE",
1304 "[\x00-\ud7ff\ue000-\U0010ffff]",
1305 "[\ud800-\udfff]",
1306 :int{0}
1307 }
1308 {
1309 "UTF-32",
1310 "[\x00-\ud7ff\ue000-\U0010ffff]",
1311 "[\ud800-\udfff]",
1312 :int{0}
1313 }
1314 {
1315 "UTF-32BE",
1316 "[\x00-\ud7ff\ue000-\U0010ffff]",
1317 "[\ud800-\udfff]",
1318 :int{0}
1319 }
1320 {
1321 "UTF-32LE",
1322 "[\x00-\ud7ff\ue000-\U0010ffff]",
1323 "[\ud800-\udfff]",
1324 :int{0}
1325 }
1326
1327 // Unicode charsets that do map surrogate code points
1328 {
1329 "UTF-7",
1330 "[\x00-\U0010ffff]",
1331 "[]",
1332 :int{0}
1333 }
1334 {
1335 "SCSU",
1336 "[\x00-\U0010ffff]",
1337 "[]",
1338 :int{0}
1339 }
1340 {
1341 "BOCU-1",
1342 "[\x00-\U0010ffff]",
1343 "[]",
1344 :int{0}
1345 }
1346 {
1347 "CESU-8",
1348 "[\x00-\U0010ffff]",
1349 "[]",
1350 :int{0}
1351 }
1352
1353 // versions of ISO-2022-KR
374ca955
A
1354 {
1355 "ISO-2022-KR",
73c04bcf
A
1356 "[\x00-\x0d\x10-\x1a\x1c-\x7f\xa1\xa4\xfe\u0111\u4e00\u4e01\uac00-\uac02\uffe6]",
1357 "[\x0e\x0f\x1b\x80-\xa0\xa3\xa5\xff-\u0110\uac03\uffe7-\U0010ffff]",
1358 :int{0}
1359 }
1360 {
1361 "ibm-25546",
1362 "[\x00-\x0d\x10-\x1a\x1c-\x7f\xa1\xa4\xfe\u0111\u4e00\u4e01\uac00-\uac01\uffe6]",
1363 "[\x0e\x0f\x1b\x80-\xa0\xa3\xa5\xff-\u0110\uac02\uffe7-\U0010ffff]",
374ca955
A
1364 :int{0}
1365 }
1366
1367 // versions of ISO-2022-JP
1368 {
1369 "ISO-2022-JP",
73c04bcf
A
1370 "[\x00-\x0d\x10-\x1a\x1c-\x7f\u0391-\u03a1\uff61-\uff9f\u4e00\u4e01\uffe5]",
1371 "[\x0e\x0f\x1b\u0100-\u0113\u0385-\u038a\u4e02\u4e27-\u4e29\uffe6-\U0010ffff]",
374ca955
A
1372 :int{0}
1373 }
1374 {
1375 "ISO-2022-JP-2",
73c04bcf
A
1376 "[\x00-\x0d\x10-\x1a\x1c-\u0113\u0385-\u038a\u0390-\u03a1\uff61-\uff9f\u4e00-\u4e05\uffe6]",
1377 "[\x0e\x0f\x1b\uffe7-\U0010ffff]",
374ca955
A
1378 :int{0}
1379 }
1380
1381 // versions of ISO-2022-CN
1382 {
1383 "ISO-2022-CN",
73c04bcf
A
1384 "[\x00-\x0d\x10-\x1a\x1c-\x7f\u4e00\u4e01\u9f98\ufe6b]",
1385 "[\x0e\x0f\x1b\u4e29\uffe6-\U0010ffff]",
374ca955
A
1386 :int{0}
1387 }
1388 {
1389 "ISO-2022-CN-EXT",
73c04bcf
A
1390 "[\x00-\x0d\x10-\x1a\x1c-\x7f\u4e00-\u4e05\u9f98\ufe6b\u4e28-\u4e2b\U00020000\U00020003-\U00020005\U00029664]",
1391 "[\x0e\x0f\x1b\U00020001\U00020002\U0002a6d7-\U0010ffff]",
374ca955
A
1392 :int{0}
1393 }
1394
1395 // DBCS-only
1396 {
1397 "ibm-971",
1398 "[\xa1\xa4\uac01\ub000]",
1399 "[\x00-\x9f\u2015]",
1400 :int{0}
1401 }
1402
1403 {
1404 "ibm-16684",
1405 "[\xa0\xa1\xa4\xa6-\xab\xad-\u017f\u0254\u309b-\u30ff\u4e00-\u4e05\U00023d00\U000243bc\U0002a6b2"
1406 "{\u0254\u0300}{\u0254\u0301}{\u304b\u309a}{\u30ad\u309a}{\u30af\u309a}]",
1407 "[\x00-0x9f\xa2\xa3\xa5\xac\u0200-\u024f\U00010000-\U0001ffff\U0002a61b-\U0002a6b1]",
1408 :int{0}
1409 }
1410
1411 // extensions
1412 {
1413 "ibm-1390",
1414 "[\x00-\x0d\x10-\u017f\u0254\u309b-\u30ff\u4e00-\u4e05\U00023d00\U000243bc\U0002a6b2"
1415 "{\u0254\u0300}{\u0254\u0301}{\u304b\u309a}{\u30ad\u309a}{\u30af\u309a}]",
1416 "[\x0e\x0f\u0200-\u024f\U00010000-\U0001ffff\U0002a61b-\U0002a6b1]",
1417 :int{0}
1418 }
1419
1420 {
1421 "*test3",
1422 "[\x05\x0b\xc0\u20ac\U00023456\U00101234"
1423 "{\U00101234\U00050005\U00060006}{\U00101234\U00050005}{\U00101234\U00060006}{\xc4\xc4\U00101234\x05}]",
1424 "[\x06\x0e\U00034567\U000febcd{\U00101234\U00070007}]",
1425 :int{0}
1426 }
1427 }
1428 }
1429 }
1430}