]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
75bd9771 | 2 | * "$Id: testi18n.c 7560 2008-05-13 06:34:04Z mike $" |
ef416fc2 | 3 | * |
4 | * Internationalization test for Common UNIX Printing System (CUPS). | |
5 | * | |
58dc1933 | 6 | * Copyright 2007-2008 by Apple Inc. |
e1d6a774 | 7 | * Copyright 1997-2006 by Easy Software Products. |
ef416fc2 | 8 | * |
bc44d920 | 9 | * These coded instructions, statements, and computer programs are the |
10 | * property of Apple Inc. and are protected by Federal copyright | |
11 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
12 | * which should have been included with this file. If this file is | |
13 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
ef416fc2 | 14 | * |
bc44d920 | 15 | * This file is subject to the Apple OS-Developed Software exception. |
ef416fc2 | 16 | * |
17 | * Contents: | |
18 | * | |
89d46774 | 19 | * main() - Main entry for internationalization test module. |
20 | * print_utf8() - Print UTF-8 string with (optional) message. | |
ef416fc2 | 21 | */ |
22 | ||
23 | /* | |
24 | * Include necessary headers... | |
25 | */ | |
26 | ||
27 | #include <stdio.h> | |
28 | #include <stdlib.h> | |
29 | #include <errno.h> | |
30 | #include <time.h> | |
89d46774 | 31 | #include <unistd.h> |
ef416fc2 | 32 | |
e1d6a774 | 33 | #include "i18n.h" |
ef416fc2 | 34 | #include "string.h" |
ef416fc2 | 35 | |
36 | ||
37 | /* | |
38 | * Local functions... | |
39 | */ | |
40 | ||
ef416fc2 | 41 | static void print_utf8(const char *msg, const cups_utf8_t *src); |
ef416fc2 | 42 | |
43 | ||
44 | /* | |
45 | * 'main()' - Main entry for internationalization test module. | |
46 | */ | |
47 | ||
48 | int /* O - Exit code */ | |
49 | main(int argc, /* I - Argument Count */ | |
50 | char *argv[]) /* I - Arguments */ | |
ef416fc2 | 51 | { |
52 | FILE *fp; /* File pointer */ | |
53 | int count; /* File line counter */ | |
e1d6a774 | 54 | int status, /* Status of current test */ |
55 | errors; /* Error count */ | |
ef416fc2 | 56 | char line[1024]; /* File line source string */ |
57 | int len; /* Length (count) of string */ | |
e1d6a774 | 58 | char legsrc[1024], /* Legacy source string */ |
59 | legdest[1024], /* Legacy destination string */ | |
60 | *legptr; /* Pointer into legacy string */ | |
ef416fc2 | 61 | cups_utf8_t utf8latin[] = /* UTF-8 Latin-1 source */ |
62 | { 0x41, 0x20, 0x21, 0x3D, 0x20, 0xC3, 0x84, 0x2E, 0x00 }; | |
63 | /* "A != <A WITH DIAERESIS>." - use ISO 8859-1 */ | |
64 | cups_utf8_t utf8repla[] = /* UTF-8 Latin-1 replacement */ | |
65 | { 0x41, 0x20, 0xE2, 0x89, 0xA2, 0x20, 0xC3, 0x84, 0x2E, 0x00 }; | |
66 | /* "A <NOT IDENTICAL TO> <A WITH DIAERESIS>." */ | |
67 | cups_utf8_t utf8greek[] = /* UTF-8 Greek source string */ | |
68 | { 0x41, 0x20, 0x21, 0x3D, 0x20, 0xCE, 0x91, 0x2E, 0x00 }; | |
e1d6a774 | 69 | /* "A != <ALPHA>." - use ISO 8859-7 */ |
ef416fc2 | 70 | cups_utf8_t utf8japan[] = /* UTF-8 Japanese source */ |
71 | { 0x41, 0x20, 0x21, 0x3D, 0x20, 0xEE, 0x9C, 0x80, 0x2E, 0x00 }; | |
72 | /* "A != <PRIVATE U+E700>." - use Windows 932 or EUC-JP */ | |
73 | cups_utf8_t utf8taiwan[] = /* UTF-8 Chinese source */ | |
74 | { 0x41, 0x20, 0x21, 0x3D, 0x20, 0xE4, 0xB9, 0x82, 0x2E, 0x00 }; | |
75 | /* "A != <CJK U+4E42>." - use Windows 950 (Big5) or EUC-TW */ | |
ef416fc2 | 76 | cups_utf8_t utf8dest[1024]; /* UTF-8 destination string */ |
ef416fc2 | 77 | cups_utf32_t utf32dest[1024]; /* UTF-32 destination string */ |
ef416fc2 | 78 | |
79 | ||
89d46774 | 80 | /* |
81 | * Make sure we have a symbolic link from the data directory to a | |
82 | * "charmaps" directory, and then point the library at it... | |
83 | */ | |
84 | ||
85 | if (access("charmaps", 0)) | |
86 | symlink("../data", "charmaps"); | |
87 | ||
88 | putenv("CUPS_DATADIR=."); | |
89 | ||
ef416fc2 | 90 | /* |
e1d6a774 | 91 | * Start with some conversion tests from a UTF-8 test file. |
ef416fc2 | 92 | */ |
93 | ||
e1d6a774 | 94 | errors = 0; |
95 | ||
96 | if ((fp = fopen("utf8demo.txt", "r")) == NULL) | |
ef416fc2 | 97 | { |
e1d6a774 | 98 | perror("utf8demo.txt"); |
99 | return (1); | |
ef416fc2 | 100 | } |
101 | ||
102 | /* | |
e1d6a774 | 103 | * cupsUTF8ToUTF32 |
ef416fc2 | 104 | */ |
105 | ||
e1d6a774 | 106 | fputs("cupsUTF8ToUTF32 of utfdemo.txt: ", stdout); |
107 | ||
108 | for (count = 0, status = 0; fgets(line, sizeof(line), fp);) | |
ef416fc2 | 109 | { |
e1d6a774 | 110 | count ++; |
111 | ||
112 | if (cupsUTF8ToUTF32(utf32dest, (cups_utf8_t *)line, 1024) < 0) | |
113 | { | |
114 | printf("FAIL (UTF-8 to UTF-32 on line %d)\n", count); | |
115 | errors ++; | |
116 | status = 1; | |
117 | break; | |
118 | } | |
ef416fc2 | 119 | } |
120 | ||
e1d6a774 | 121 | if (!status) |
122 | puts("PASS"); | |
ef416fc2 | 123 | |
e1d6a774 | 124 | /* |
125 | * cupsUTF8ToCharset(CUPS_EUC_JP) | |
126 | */ | |
ef416fc2 | 127 | |
e1d6a774 | 128 | fputs("cupsUTF8ToCharset(CUPS_EUC_JP) of utfdemo.txt: ", stdout); |
ef416fc2 | 129 | |
e1d6a774 | 130 | rewind(fp); |
131 | ||
132 | for (count = 0, status = 0; fgets(line, sizeof(line), fp);) | |
133 | { | |
134 | count ++; | |
ef416fc2 | 135 | |
136 | len = cupsUTF8ToCharset(legdest, (cups_utf8_t *)line, 1024, CUPS_EUC_JP); | |
137 | if (len < 0) | |
e1d6a774 | 138 | { |
139 | printf("FAIL (UTF-8 to EUC-JP on line %d)\n", count); | |
140 | errors ++; | |
141 | status = 1; | |
142 | break; | |
143 | } | |
ef416fc2 | 144 | } |
145 | ||
e1d6a774 | 146 | if (!status) |
147 | puts("PASS"); | |
148 | ||
ef416fc2 | 149 | fclose(fp); |
150 | ||
e1d6a774 | 151 | /* |
152 | * Test charmap load for ISO-8859-1... | |
153 | */ | |
154 | ||
155 | fputs("_cupsCharmapGet(CUPS_ISO8859_1): ", stdout); | |
156 | ||
157 | if (!_cupsCharmapGet(CUPS_ISO8859_1)) | |
158 | { | |
159 | errors ++; | |
160 | puts("FAIL"); | |
161 | } | |
162 | else | |
163 | puts("PASS"); | |
ef416fc2 | 164 | |
165 | /* | |
e1d6a774 | 166 | * Test charmap load for Windows-932 (Shift-JIS)... |
ef416fc2 | 167 | */ |
168 | ||
e1d6a774 | 169 | fputs("_cupsCharmapGet(CUPS_WINDOWS_932): ", stdout); |
ef416fc2 | 170 | |
e1d6a774 | 171 | if (!_cupsCharmapGet(CUPS_WINDOWS_932)) |
172 | { | |
173 | errors ++; | |
174 | puts("FAIL"); | |
175 | } | |
176 | else | |
177 | puts("PASS"); | |
ef416fc2 | 178 | |
e1d6a774 | 179 | /* |
180 | * Test VBCS charmap load for EUC-JP... | |
181 | */ | |
182 | ||
183 | fputs("_cupsCharmapGet(CUPS_EUC_JP): ", stdout); | |
184 | ||
d09495fa | 185 | if (!_cupsCharmapGet(CUPS_EUC_JP)) |
ef416fc2 | 186 | { |
e1d6a774 | 187 | errors ++; |
188 | puts("FAIL"); | |
ef416fc2 | 189 | } |
e1d6a774 | 190 | else |
191 | puts("PASS"); | |
ef416fc2 | 192 | |
193 | /* | |
194 | * Test VBCS charmap load for EUC-TW... | |
195 | */ | |
196 | ||
e1d6a774 | 197 | fputs("_cupsCharmapGet(CUPS_EUC_TW): ", stdout); |
ef416fc2 | 198 | |
d09495fa | 199 | if (!_cupsCharmapGet(CUPS_EUC_TW)) |
ef416fc2 | 200 | { |
e1d6a774 | 201 | errors ++; |
202 | puts("FAIL"); | |
ef416fc2 | 203 | } |
e1d6a774 | 204 | else |
205 | puts("PASS"); | |
ef416fc2 | 206 | |
207 | /* | |
208 | * Test UTF-8 to legacy charset (ISO 8859-1)... | |
209 | */ | |
210 | ||
e1d6a774 | 211 | fputs("cupsUTF8ToCharset(CUPS_ISO8859_1): ", stdout); |
ef416fc2 | 212 | |
213 | legdest[0] = 0; | |
214 | ||
215 | len = cupsUTF8ToCharset(legdest, utf8latin, 1024, CUPS_ISO8859_1); | |
216 | if (len < 0) | |
ef416fc2 | 217 | { |
e1d6a774 | 218 | printf("FAIL (len=%d)\n", len); |
219 | errors ++; | |
ef416fc2 | 220 | } |
e1d6a774 | 221 | else |
222 | puts("PASS"); | |
ef416fc2 | 223 | |
e1d6a774 | 224 | /* |
225 | * cupsCharsetToUTF8 | |
226 | */ | |
ef416fc2 | 227 | |
e1d6a774 | 228 | fputs("cupsCharsetToUTF8(CUPS_ISO8859_1): ", stdout); |
ef416fc2 | 229 | |
e1d6a774 | 230 | strcpy(legsrc, legdest); |
ef416fc2 | 231 | |
e1d6a774 | 232 | len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_1); |
233 | if (len != strlen((char *)utf8latin)) | |
234 | { | |
89d46774 | 235 | printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8latin)); |
e1d6a774 | 236 | print_utf8(" utf8latin", utf8latin); |
237 | print_utf8(" utf8dest", utf8dest); | |
238 | errors ++; | |
239 | } | |
240 | else if (memcmp(utf8latin, utf8dest, len)) | |
ef416fc2 | 241 | { |
e1d6a774 | 242 | puts("FAIL (results do not match)"); |
243 | print_utf8(" utf8latin", utf8latin); | |
244 | print_utf8(" utf8dest", utf8dest); | |
245 | errors ++; | |
ef416fc2 | 246 | } |
e1d6a774 | 247 | else if (cupsUTF8ToCharset(legdest, utf8repla, 1024, CUPS_ISO8859_1) < 0) |
248 | { | |
249 | puts("FAIL (replacement characters do not work!)"); | |
250 | errors ++; | |
251 | } | |
252 | else | |
253 | puts("PASS"); | |
ef416fc2 | 254 | |
255 | /* | |
e1d6a774 | 256 | * Test UTF-8 to/from legacy charset (ISO 8859-7)... |
ef416fc2 | 257 | */ |
e1d6a774 | 258 | |
259 | fputs("cupsUTF8ToCharset(CUPS_ISO8859_7): ", stdout); | |
260 | ||
261 | if (cupsUTF8ToCharset(legdest, utf8greek, 1024, CUPS_ISO8859_7) < 0) | |
ef416fc2 | 262 | { |
e1d6a774 | 263 | puts("FAIL"); |
264 | errors ++; | |
ef416fc2 | 265 | } |
e1d6a774 | 266 | else |
267 | { | |
268 | for (legptr = legdest; *legptr && *legptr != '?'; legptr ++); | |
269 | ||
270 | if (*legptr) | |
271 | { | |
272 | puts("FAIL (unknown character)"); | |
273 | errors ++; | |
274 | } | |
275 | else | |
276 | puts("PASS"); | |
277 | } | |
278 | ||
279 | fputs("cupsCharsetToUTF8(CUPS_ISO8859_7): ", stdout); | |
280 | ||
ef416fc2 | 281 | strcpy(legsrc, legdest); |
e1d6a774 | 282 | |
ef416fc2 | 283 | len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_7); |
e1d6a774 | 284 | if (len != strlen((char *)utf8greek)) |
285 | { | |
89d46774 | 286 | printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8greek)); |
e1d6a774 | 287 | print_utf8(" utf8greek", utf8greek); |
288 | print_utf8(" utf8dest", utf8dest); | |
289 | errors ++; | |
290 | } | |
291 | else if (memcmp(utf8greek, utf8dest, len)) | |
292 | { | |
293 | puts("FAIL (results do not match)"); | |
294 | print_utf8(" utf8greek", utf8greek); | |
295 | print_utf8(" utf8dest", utf8dest); | |
296 | errors ++; | |
297 | } | |
298 | else | |
299 | puts("PASS"); | |
ef416fc2 | 300 | |
301 | /* | |
e1d6a774 | 302 | * Test UTF-8 to/from legacy charset (Windows 932)... |
ef416fc2 | 303 | */ |
e1d6a774 | 304 | |
305 | fputs("cupsUTF8ToCharset(CUPS_WINDOWS_932): ", stdout); | |
306 | ||
307 | if (cupsUTF8ToCharset(legdest, utf8japan, 1024, CUPS_WINDOWS_932) < 0) | |
ef416fc2 | 308 | { |
e1d6a774 | 309 | puts("FAIL"); |
310 | errors ++; | |
ef416fc2 | 311 | } |
e1d6a774 | 312 | else |
313 | { | |
314 | for (legptr = legdest; *legptr && *legptr != '?'; legptr ++); | |
315 | ||
316 | if (*legptr) | |
317 | { | |
318 | puts("FAIL (unknown character)"); | |
319 | errors ++; | |
320 | } | |
321 | else | |
322 | puts("PASS"); | |
323 | } | |
324 | ||
325 | fputs("cupsCharsetToUTF8(CUPS_WINDOWS_932): ", stdout); | |
326 | ||
ef416fc2 | 327 | strcpy(legsrc, legdest); |
e1d6a774 | 328 | |
ef416fc2 | 329 | len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_932); |
e1d6a774 | 330 | if (len != strlen((char *)utf8japan)) |
331 | { | |
89d46774 | 332 | printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8japan)); |
e1d6a774 | 333 | print_utf8(" utf8japan", utf8japan); |
334 | print_utf8(" utf8dest", utf8dest); | |
335 | errors ++; | |
336 | } | |
337 | else if (memcmp(utf8japan, utf8dest, len)) | |
338 | { | |
339 | puts("FAIL (results do not match)"); | |
340 | print_utf8(" utf8japan", utf8japan); | |
341 | print_utf8(" utf8dest", utf8dest); | |
342 | errors ++; | |
343 | } | |
344 | else | |
345 | puts("PASS"); | |
ef416fc2 | 346 | |
347 | /* | |
e1d6a774 | 348 | * Test UTF-8 to/from legacy charset (EUC-JP)... |
ef416fc2 | 349 | */ |
e1d6a774 | 350 | |
351 | fputs("cupsUTF8ToCharset(CUPS_EUC_JP): ", stdout); | |
352 | ||
353 | if (cupsUTF8ToCharset(legdest, utf8japan, 1024, CUPS_EUC_JP) < 0) | |
ef416fc2 | 354 | { |
e1d6a774 | 355 | puts("FAIL"); |
356 | errors ++; | |
ef416fc2 | 357 | } |
e1d6a774 | 358 | else |
359 | { | |
360 | for (legptr = legdest; *legptr && *legptr != '?'; legptr ++); | |
361 | ||
362 | if (*legptr) | |
363 | { | |
364 | puts("FAIL (unknown character)"); | |
365 | errors ++; | |
366 | } | |
367 | else | |
368 | puts("PASS"); | |
369 | } | |
370 | ||
371 | fputs("cupsCharsetToUTF8(CUPS_EUC_JP): ", stdout); | |
372 | ||
ef416fc2 | 373 | strcpy(legsrc, legdest); |
e1d6a774 | 374 | |
ef416fc2 | 375 | len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_JP); |
e1d6a774 | 376 | if (len != strlen((char *)utf8japan)) |
377 | { | |
89d46774 | 378 | printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8japan)); |
e1d6a774 | 379 | print_utf8(" utf8japan", utf8japan); |
380 | print_utf8(" utf8dest", utf8dest); | |
381 | errors ++; | |
382 | } | |
383 | else if (memcmp(utf8japan, utf8dest, len)) | |
384 | { | |
385 | puts("FAIL (results do not match)"); | |
386 | print_utf8(" utf8japan", utf8japan); | |
387 | print_utf8(" utf8dest", utf8dest); | |
388 | errors ++; | |
389 | } | |
390 | else | |
391 | puts("PASS"); | |
ef416fc2 | 392 | |
393 | /* | |
e1d6a774 | 394 | * Test UTF-8 to/from legacy charset (Windows 950)... |
ef416fc2 | 395 | */ |
e1d6a774 | 396 | |
397 | fputs("cupsUTF8ToCharset(CUPS_WINDOWS_950): ", stdout); | |
398 | ||
399 | if (cupsUTF8ToCharset(legdest, utf8taiwan, 1024, CUPS_WINDOWS_950) < 0) | |
400 | { | |
401 | puts("FAIL"); | |
402 | errors ++; | |
403 | } | |
404 | else | |
ef416fc2 | 405 | { |
e1d6a774 | 406 | for (legptr = legdest; *legptr && *legptr != '?'; legptr ++); |
407 | ||
408 | if (*legptr) | |
409 | { | |
410 | puts("FAIL (unknown character)"); | |
411 | errors ++; | |
412 | } | |
413 | else | |
414 | puts("PASS"); | |
ef416fc2 | 415 | } |
e1d6a774 | 416 | |
417 | fputs("cupsCharsetToUTF8(CUPS_WINDOWS_950): ", stdout); | |
418 | ||
ef416fc2 | 419 | strcpy(legsrc, legdest); |
e1d6a774 | 420 | |
ef416fc2 | 421 | len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_950); |
e1d6a774 | 422 | if (len != strlen((char *)utf8taiwan)) |
423 | { | |
89d46774 | 424 | printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8taiwan)); |
e1d6a774 | 425 | print_utf8(" utf8taiwan", utf8taiwan); |
426 | print_utf8(" utf8dest", utf8dest); | |
427 | errors ++; | |
428 | } | |
429 | else if (memcmp(utf8taiwan, utf8dest, len)) | |
430 | { | |
431 | puts("FAIL (results do not match)"); | |
432 | print_utf8(" utf8taiwan", utf8taiwan); | |
433 | print_utf8(" utf8dest", utf8dest); | |
434 | errors ++; | |
435 | } | |
436 | else | |
437 | puts("PASS"); | |
ef416fc2 | 438 | |
439 | /* | |
e1d6a774 | 440 | * Test UTF-8 to/from legacy charset (EUC-TW)... |
ef416fc2 | 441 | */ |
e1d6a774 | 442 | |
443 | fputs("cupsUTF8ToCharset(CUPS_EUC_TW): ", stdout); | |
444 | ||
445 | if (cupsUTF8ToCharset(legdest, utf8taiwan, 1024, CUPS_EUC_TW) < 0) | |
446 | { | |
447 | puts("FAIL"); | |
448 | errors ++; | |
449 | } | |
450 | else | |
ef416fc2 | 451 | { |
e1d6a774 | 452 | for (legptr = legdest; *legptr && *legptr != '?'; legptr ++); |
453 | ||
454 | if (*legptr) | |
455 | { | |
456 | puts("FAIL (unknown character)"); | |
457 | errors ++; | |
458 | } | |
459 | else | |
460 | puts("PASS"); | |
ef416fc2 | 461 | } |
e1d6a774 | 462 | |
463 | fputs("cupsCharsetToUTF8(CUPS_EUC_TW): ", stdout); | |
464 | ||
ef416fc2 | 465 | strcpy(legsrc, legdest); |
e1d6a774 | 466 | |
ef416fc2 | 467 | len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_TW); |
e1d6a774 | 468 | if (len != strlen((char *)utf8taiwan)) |
469 | { | |
89d46774 | 470 | printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8taiwan)); |
e1d6a774 | 471 | print_utf8(" utf8taiwan", utf8taiwan); |
472 | print_utf8(" utf8dest", utf8dest); | |
473 | errors ++; | |
474 | } | |
475 | else if (memcmp(utf8taiwan, utf8dest, len)) | |
476 | { | |
477 | puts("FAIL (results do not match)"); | |
478 | print_utf8(" utf8taiwan", utf8taiwan); | |
479 | print_utf8(" utf8dest", utf8dest); | |
480 | errors ++; | |
481 | } | |
482 | else | |
483 | puts("PASS"); | |
ef416fc2 | 484 | |
e1d6a774 | 485 | #if 0 |
ef416fc2 | 486 | /* |
487 | * Test UTF-8 (16-bit) to UTF-32 (w/ BOM)... | |
488 | */ | |
489 | if (verbose) | |
490 | printf("\ntesti18n: Testing UTF-8 to UTF-32 (w/ BOM)...\n"); | |
491 | len = cupsUTF8ToUTF32(utf32dest, utf8good, 1024); | |
492 | if (len < 0) | |
493 | return (1); | |
494 | if (verbose) | |
495 | { | |
496 | print_utf8(" utf8good ", utf8good); | |
497 | print_utf32(" utf32dest", utf32dest); | |
498 | } | |
499 | memcpy (utf32src, utf32dest, (len + 1) * sizeof(cups_utf32_t)); | |
500 | len = cupsUTF32ToUTF8(utf8dest, utf32src, 1024); | |
501 | if (len < 0) | |
502 | return (1); | |
503 | if (len != strlen ((char *) utf8good)) | |
504 | return (1); | |
505 | if (memcmp(utf8good, utf8dest, len) != 0) | |
506 | return (1); | |
507 | ||
508 | /* | |
509 | * Test invalid UTF-8 (16-bit) to UTF-32 (w/ BOM)... | |
510 | */ | |
511 | if (verbose) | |
512 | printf("\ntesti18n: Testing UTF-8 bad 16-bit source string...\n"); | |
513 | len = cupsUTF8ToUTF32(utf32dest, utf8bad, 1024); | |
514 | if (len >= 0) | |
515 | return (1); | |
516 | if (verbose) | |
517 | print_utf8(" utf8bad ", utf8bad); | |
518 | ||
519 | /* | |
e1d6a774 | 520 | * Test _cupsCharmapFlush()... |
ef416fc2 | 521 | */ |
522 | if (verbose) | |
e1d6a774 | 523 | printf("\ntesti18n: Testing _cupsCharmapFlush()...\n"); |
524 | _cupsCharmapFlush(); | |
ef416fc2 | 525 | return (0); |
e1d6a774 | 526 | #endif /* 0 */ |
527 | ||
528 | return (errors > 0); | |
ef416fc2 | 529 | } |
530 | ||
531 | ||
532 | /* | |
e1d6a774 | 533 | * 'print_utf8()' - Print UTF-8 string with (optional) message. |
ef416fc2 | 534 | */ |
535 | ||
e1d6a774 | 536 | static void |
537 | print_utf8(const char *msg, /* I - Message String */ | |
538 | const cups_utf8_t *src) /* I - UTF-8 Source String */ | |
ef416fc2 | 539 | { |
58dc1933 MS |
540 | const char *prefix; /* Prefix string */ |
541 | ||
542 | ||
e1d6a774 | 543 | if (msg) |
544 | printf("%s:", msg); | |
ef416fc2 | 545 | |
58dc1933 MS |
546 | for (prefix = " "; *src; src ++) |
547 | { | |
548 | printf("%s%02x", prefix, *src); | |
549 | ||
550 | if ((src[0] & 0x80) && (src[1] & 0x80)) | |
551 | prefix = ""; | |
552 | else | |
553 | prefix = " "; | |
554 | } | |
ef416fc2 | 555 | |
e1d6a774 | 556 | putchar('\n'); |
557 | } | |
ef416fc2 | 558 | |
ef416fc2 | 559 | |
e1d6a774 | 560 | /* |
75bd9771 | 561 | * End of "$Id: testi18n.c 7560 2008-05-13 06:34:04Z mike $" |
ef416fc2 | 562 | */ |