summaryrefslogtreecommitdiff
path: root/cups/testi18n.c
blob: 8b0fbad2f6c5dd6470601f2579066cca01ed97e5 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
/*
 * "$Id: testi18n.c 5195 2006-02-27 21:05:46Z mike $"
 *
 *   Internationalization test for Common UNIX Printing System (CUPS).
 *
 *   Copyright 1997-2005 by Easy Software Products.
 *
 *   These coded instructions, statements, and computer programs are
 *   the property of Easy Software Products and are protected by Federal
 *   copyright law.  Distribution and use rights are outlined in the
 *   file "LICENSE.txt" which should have been included with this file.
 *   If this file is missing or damaged please contact Easy Software
 *   Products at:
 *
 *       Attn: CUPS Licensing Information
 *       Easy Software Products
 *       44141 Airport View Drive, Suite 204
 *       Hollywood, Maryland 20636 USA
 *
 *       Voice: (301) 373-9600
 *       EMail: cups-info@cups.org
 *         WWW: http://www.cups.org
 *
 * Contents:
 *
 *   main()           - Main entry for internationalization test module.
 *   print_synopsis() - Print program synopsis (help).
 *   print_utf8()     - Print UTF-8 string with (optional) message.
 *   print_utf16()    - Print UTF-16 string with (optional) message.
 *   print_utf32()    - Print UTF-32 string with (optional) message.
 *   test_transcode() - Test 'transcode.c' module.
 *   test_normalize() - Test 'normalize.c' module.
 */

/*
 * Include necessary headers...
 */

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>

#include "language.h"
#include "string.h"
#include "transcode.h"
#include "normalize.h"


/*
 * Local Globals...
 */

static const char *program_synopsis[] = /* Program help */
{
  "testi18n [-vh]",
  "         -v  verbose (print each called function and result)",
  "         -h  help (print this synopsis)",
  "",
  "'testi18n' is a utility to test CUPS internationalization",
  "Copyright 1997-2005 by Easy Software Products.",
  NULL
};
static int	error_count = 0;	/* Total error count */


/*
 * Local functions...
 */

static void	print_synopsis(void);
static void	print_utf8(const char *msg, const cups_utf8_t *src);
static void	print_utf16(const char *msg, const cups_utf16_t *src);
static void	print_utf32(const char *msg, const cups_utf32_t *src);
static int	test_transcode(const int verbose);
static int	test_normalize(const int verbose);


/*
 * 'main()' - Main entry for internationalization test module.
 */

int					/* O - Exit code */
main(int  argc,				/* I - Argument Count */
     char *argv[])			/* I - Arguments */
{
  int		ai;			/* Argument index */
  char		*ap;			/* Argument pointer */
  int		verbose;		/* Verbose flag */
  int		errors;			/* Error count */


 /*
  * Check for switches...
  */

  verbose = 0;

  for (ai = 1; ai < argc; ai ++)
  {
    ap = argv[ai];
    if (*ap != '-')
      break;

    for (ap ++; *ap != '\0'; ap ++)
    {
      switch (*ap)
      {
	case 'v':			/* verbose */
	  verbose = 1;
	  break;

	case 'h':			/* help */
	  print_synopsis();
	  return (0);

	default:
	  print_synopsis();
	  return (1);
      }
    }
  }

 /*
  * Test all internationalization modules and functions...
  */

  errors = test_transcode(verbose);
  error_count += errors;
  printf("\ntesti18n: %d errors found in 'transcode.c'\n", errors);

  errors = test_normalize(verbose);
  error_count += errors;
  printf("\ntesti18n: %d errors found in 'normalize.c'\n", errors);

  return (error_count > 0);
}


/*
 * 'print_synopsis()' - Print program synopsis (help).
 */

static void
print_synopsis(void)
{
  int	i;				/* Looping variable */


  for (i = 0; program_synopsis[i]; i ++)
    puts(program_synopsis[i]);
}


/*
 * 'print_utf8()' - Print UTF-8 string with (optional) message.
 */

static void
print_utf8(const char	     *msg,	/* I - Message String */
	   const cups_utf8_t *src)	/* I - UTF-8 Source String */
{
  if (msg != NULL)
    printf("%s:", msg);

  for (; *src; src ++)
    printf(" %02x", *src);
  printf("\n");
  return;
}


/*
 * 'print_utf16()' - Print UTF-16 string with (optional) message.
 */

static void
print_utf16(const char	       *msg,	/* I - Message String */
	    const cups_utf16_t *src)	/* I - UTF-16 Source String */
{
  if (msg != NULL)
    printf("%s:", msg);
  for (; *src; src ++)
    printf(" %04x", (int) *src);
  printf("\n");
  return;
}


/*
 * 'print_utf32()' - Print UTF-32 string with (optional) message.
 */

static void
print_utf32(const char	       *msg,	/* I - Message String */
	    const cups_utf32_t *src)	/* I - UTF-32 Source String */
{
  if (msg != NULL)
    printf("%s:", msg);
  for (; *src; src ++)
    printf(" %04x", (int) *src);
  printf("\n");
  return;
}


/*
 * 'test_transcode()' - Test 'transcode.c' module.
 */

static int				/* O - Zero or error count */
test_transcode(const int verbose)	/* I - Verbose flag */
{
  FILE		*fp;			/* File pointer */
  int		count;			/* File line counter */
  char		line[1024];		/* File line source string */
  int		len;			/* Length (count) of string */
  char		legsrc[1024];		/* Legacy source string */
  char		legdest[1024];		/* Legacy destination string */
  cups_utf8_t	utf8latin[] =		/* UTF-8 Latin-1 source */
    { 0x41, 0x20, 0x21, 0x3D, 0x20, 0xC3, 0x84, 0x2E, 0x00 };
    /* "A != <A WITH DIAERESIS>." - use ISO 8859-1 */
  cups_utf8_t	utf8repla[] =		/* UTF-8 Latin-1 replacement */
    { 0x41, 0x20, 0xE2, 0x89, 0xA2, 0x20, 0xC3, 0x84, 0x2E, 0x00 };
    /* "A <NOT IDENTICAL TO> <A WITH DIAERESIS>." */
  cups_utf8_t	utf8greek[] =		/* UTF-8 Greek source string */
    { 0x41, 0x20, 0x21, 0x3D, 0x20, 0xCE, 0x91, 0x2E, 0x00 };
    /* "A != <ALHPA>." - use ISO 8859-7 */
  cups_utf8_t	utf8japan[] =		/* UTF-8 Japanese source */
    { 0x41, 0x20, 0x21, 0x3D, 0x20, 0xEE, 0x9C, 0x80, 0x2E, 0x00 };
    /* "A != <PRIVATE U+E700>." - use Windows 932 or EUC-JP */
  cups_utf8_t	utf8taiwan[] =		/* UTF-8 Chinese source */
    { 0x41, 0x20, 0x21, 0x3D, 0x20, 0xE4, 0xB9, 0x82, 0x2E, 0x00 };
    /* "A != <CJK U+4E42>." - use Windows 950 (Big5) or EUC-TW */
  cups_utf8_t	utf8good[] =		/* UTF-8 good 16-bit source */
    { 0x41, 0x20, 0xE2, 0x89, 0xA2, 0x20, 0xC3, 0x84, 0x2E, 0x00 };
    /* "A <NOT IDENTICAL TO> <A WITH DIAERESIS>." */
  cups_utf8_t	utf8bad[] =		/* UTF-8 bad 16-bit source */
    { 0x41, 0x20, 0xE2, 0x89, 0xA2, 0x20, 0xF8, 0x84, 0x2E, 0x00 };
    /* "A <NOT IDENTICAL TO> <...bad stuff...>." */
  cups_utf8_t	utf8dest[1024];		/* UTF-8 destination string */
  cups_utf16_t	utf16sur[] =		/* UTF-16 with surrogates */
    { 0xD800, 0xDC00, 0x20, 0x21, 0x3D, 0x20, 0xC4, 0x2E, 0x00 };
    /* "<Surrogate pair> != <A WITH DIAERESIS>." */
  cups_utf16_t	utf16src[1024];		/* UTF-16 source string */
  cups_utf16_t	utf16dest[1024];	/* UTF-16 destination string */
  cups_utf32_t	utf32src[1024];		/* UTF-32 source string */
  cups_utf32_t	utf32dest[1024];	/* UTF-32 destination string */
  _cups_vmap_t	 *vmap;			 /* VBCS charmap pointer */


 /*
  * Test with (inserted) and (deleted) leading BOM...
  */

  if (verbose)
  {
    printf("\ntesti18n: Testing 'transcode.c'...\n");
    printf(" testing with insert/delete leading BOM...\n");
  }

 /*
  * Test UTF-8 to UTF-32/EUC-JP on demo file...
  */

  if (verbose)
  {
    printf("\ntesti18n: Testing UTF-8 source 'utf8demo.txt'...\n");
    printf(" testing UTF-8 to UTF-32...\n");
    printf(" testing UTF-8 to EUC-JP...\n");
  }

  if ((fp = fopen("utf8demo.txt", "r")) == NULL)
    return (1);

  for (count = 0;;)
  {
    if (fgets(line, 1024, fp) == NULL)
      break;

    count ++;

    len = cupsUTF8ToUTF32(utf32dest, (cups_utf8_t *)line, 1024);
    if (len < 0)
      printf(" error line: %d (UTF-8 to UTF-32)\n", count);

    len = cupsUTF8ToCharset(legdest, (cups_utf8_t *)line, 1024, CUPS_EUC_JP);
    if (len < 0)
      printf(" error line: %d (UTF-8 to EUC-JP)\n", count);
  }

  fclose(fp);

  if (verbose)
    printf(" total lines: %d\n", count);

 /*
  * Test VBCS charmap load for EUC-JP...
  */

  if (verbose)
    printf("\ntesti18n: Loading VBCS charmap EUC-JP (Japanese)...\n");

  vmap = (_cups_vmap_t *) cupsCharmapGet(CUPS_EUC_JP);
  if (vmap == NULL)
    return (1);

  if (verbose)
  {
    printf(" charcount: %d\n", vmap->charcount);
    printf(" widecount: %d\n", vmap->widecount);
  }

 /*
  * Test VBCS charmap load for EUC-TW...
  */

  if (verbose)
    printf("\ntesti18n: Loading VBCS charmap EUC-TW (Taiwan)...\n");

  vmap = (_cups_vmap_t *) cupsCharmapGet(CUPS_EUC_TW);
  if (vmap == NULL)
    return (1);

  if (verbose)
  {
    printf(" charcount: %d\n", vmap->charcount);
    printf(" widecount: %d\n", vmap->widecount);
  }

 /*
  * Test UTF-8 to legacy charset (ISO 8859-1)...
  */

  if (verbose)
    printf("\ntesti18n: Testing UTF-8 to ISO 8859-1 (Latin1)...\n");

  legdest[0] = 0;

  len = cupsUTF8ToCharset(legdest, utf8latin, 1024, CUPS_ISO8859_1);
  if (len < 0)
    return (1);

  if (verbose)
  {
    print_utf8(" utf8latin", utf8latin);
    print_utf8(" legdest  ", (cups_utf8_t *) legdest);
  }

  strcpy(legsrc, legdest);

  len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_1);

  if (len < 0)
    return (1);

  if (len != strlen ((char *) utf8latin))
    return (1);

  if (memcmp(utf8latin, utf8dest, len) != 0)
    return (1);

 /*
  * Test UTF-8 to Latin-1 (ISO 8859-1) with replacement...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 to ISO 8859-1 w/ replace...\n");
  len = cupsUTF8ToCharset(legdest, utf8repla, 1024, CUPS_ISO8859_1);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf8(" utf8repla", utf8repla);
    print_utf8(" legdest  ", (cups_utf8_t *) legdest);
  }

 /*
  * Test UTF-8 to legacy charset (ISO 8859-7)...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 to ISO 8859-7 (Greek)...\n");
  legdest[0] = 0;
  len = cupsUTF8ToCharset(legdest, utf8greek, 1024, CUPS_ISO8859_7);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf8(" utf8greek", utf8greek);
    print_utf8(" legdest  ", (cups_utf8_t *) legdest);
  }
  strcpy(legsrc, legdest);
  len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_7);
  if (len < 0)
    return (1);
  if (len != strlen ((char *) utf8greek))
    return (1);
  if (memcmp(utf8greek, utf8dest, len) != 0)
    return (1);

 /*
  * Test UTF-8 to legacy charset (Windows 932)...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 to Windows 932 (Japanese)...\n");
  legdest[0] = 0;
  len = cupsUTF8ToCharset(legdest, utf8japan, 1024, CUPS_WINDOWS_932);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf8(" utf8japan", utf8japan);
    print_utf8(" legdest  ", (cups_utf8_t *) legdest);
  }
  strcpy(legsrc, legdest);
  len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_932);
  if (len < 0)
    return (1);
  if (len != strlen ((char *) utf8japan))
    return (1);
  if (memcmp(utf8japan, utf8dest, len) != 0)
    return (1);

 /*
  * Test UTF-8 to legacy charset (EUC-JP)...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 to EUC-JP (Japanese)...\n");
  legdest[0] = 0;
  len = cupsUTF8ToCharset(legdest, utf8japan, 1024, CUPS_EUC_JP);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf8(" utf8japan", utf8japan);
    print_utf8(" legdest  ", (cups_utf8_t *) legdest);
  }
  strcpy(legsrc, legdest);
  len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_JP);
  if (len < 0)
    return (1);
  if (len != strlen ((char *) utf8japan))
    return (1);
  if (memcmp(utf8japan, utf8dest, len) != 0)
    return (1);

 /*
  * Test UTF-8 to legacy charset (Windows 950)...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 to Windows 950 (Chinese)...\n");
  legdest[0] = 0;
  len = cupsUTF8ToCharset(legdest, utf8taiwan, 1024, CUPS_WINDOWS_950);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf8(" utf8taiwan", utf8taiwan);
    print_utf8(" legdest   ", (cups_utf8_t *) legdest);
  }
  strcpy(legsrc, legdest);
  len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_950);
  if (len < 0)
    return (1);
  if (len != strlen ((char *) utf8taiwan))
    return (1);
  if (memcmp(utf8taiwan, utf8dest, len) != 0)
    return (1);

 /*
  * Test UTF-8 to legacy charset (EUC-TW)...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 to EUC-TW (Chinese)...\n");
  legdest[0] = 0;
  len = cupsUTF8ToCharset(legdest, utf8taiwan, 1024, CUPS_EUC_TW);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf8(" utf8taiwan", utf8taiwan);
    print_utf8(" legdest   ", (cups_utf8_t *) legdest);
  }
  strcpy(legsrc, legdest);
  len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_TW);
  if (len < 0)
    return (1);
  if (len != strlen ((char *) utf8taiwan))
    return (1);
  if (memcmp(utf8taiwan, utf8dest, len) != 0)
    return (1);

 /*
  * Test UTF-8 (16-bit) to UTF-32 (w/ BOM)...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 to UTF-32 (w/ BOM)...\n");
  len = cupsUTF8ToUTF32(utf32dest, utf8good, 1024);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf8(" utf8good ", utf8good);
    print_utf32(" utf32dest", utf32dest);
  }
  memcpy (utf32src, utf32dest, (len + 1) * sizeof(cups_utf32_t));
  len = cupsUTF32ToUTF8(utf8dest, utf32src, 1024);
  if (len < 0)
    return (1);
  if (len != strlen ((char *) utf8good))
    return (1);
  if (memcmp(utf8good, utf8dest, len) != 0)
    return (1);

 /*
  * Test invalid UTF-8 (16-bit) to UTF-32 (w/ BOM)...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 bad 16-bit source string...\n");
  len = cupsUTF8ToUTF32(utf32dest, utf8bad, 1024);
  if (len >= 0)
    return (1);
  if (verbose)
    print_utf8(" utf8bad  ", utf8bad);

 /*
  * Test UTF-8 (16-bit) to UTF-16 (w/ BOM)...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 to UTF-16 (w/ BOM)...\n");
  len = cupsUTF8ToUTF16(utf16dest, utf8good, 1024);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf8(" utf8good ", utf8good);
    print_utf16(" utf16dest", utf16dest);
  }
  memcpy (utf16src, utf16dest, (len + 1) * sizeof(cups_utf16_t));
  len = cupsUTF16ToUTF8(utf8dest, utf16src, 1024);
  if (len < 0)
    return (1);
  if (len != strlen ((char *) utf8good))
    return (1);
  if (memcmp(utf8good, utf8dest, len) != 0)
    return (1);

 /*
  * Test UTF-16 to UTF-32 with surrogates...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-16 to UTF-32 w/ surrogates...\n");
  len = cupsUTF16ToUTF32(utf32dest, utf16sur, 1024);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf16(" utf16sur ", utf16sur);
    print_utf32(" utf32dest", utf32dest);
  }

 /*
  * Test cupsCharmapFlush()...
  */
  if (verbose)
    printf("\ntesti18n: Testing cupsCharmapFlush()...\n");
  cupsCharmapFlush();
  return (0);
}


/*
 * 'test_normalize()' - Test 'normalize.c' module.
 */

static int				/* O - Zero or error count */
test_normalize(const int verbose)	/* I - Verbose flag */
{
  FILE		*fp;			/* File pointer */
  int		count;			/* File line counter */
  char		line[1024];		/* File line source string */
  int		len;			/* Length (count) of string */
  int		diff;			/* Difference of two strings */
  int		prop;			/* Property of a character */
  int		i;			/* Looping variable */
  cups_utf32_t	utf32char;		/* UTF-32 character */
  cups_utf8_t	utf8src[1024];		/* UTF-8 source string */
  cups_utf8_t	utf8dest[1024];		/* UTF-8 destination string */
  cups_utf16_t	utf16src[] =		/* UTF-16 non-normal source */
    { 0x0149, 0x20, 0x21, 0x3D, 0x20, 0xC4, 0x2E, 0x00 };
    /* "<SMALL N PRECEDED BY APOSTROPHE> != <A WITH DIAERESIS>." */
  cups_utf16_t	utf16dest[1024];	/* UTF-16 destination string */
  cups_utf32_t	utf32dest[1024];	/* UTF-32 destination string */

  if (verbose)
    printf("\ntesti18n: Testing 'normalize.c'...\n");

 /*
  * Test UTF-8 to NFKD/NFC/Properties on demo file...
  */
  if (verbose)
  {
    printf("\ntesti18n: Testing UTF-8 source 'utf8demo.txt'...\n");
    printf(" testing UTF-8 to NFKD...\n");
    printf(" testing UTF-8 to NFC...\n");
    printf(" testing UTF-8 to Character Properties...\n");
  }
  if ((fp = fopen("utf8demo.txt", "r")) == NULL)
    return (1);
  for (count = 0;;)
  {
    if (fgets(line, 1024, fp) == NULL)
      break;
    count ++;
    len = cupsUTF8Normalize(utf8dest, (cups_utf8_t *)line, 1024, CUPS_NORM_NFKD);
    if (len < 0)
      printf(" error line: %d (UTF-8 to NFKD)\n", count);
    len = cupsUTF8Normalize(utf8dest, (cups_utf8_t *)line, 1024, CUPS_NORM_NFC);
    if (len < 0)
      printf(" error line: %d (UTF-8 to NFC)\n", count);
    len = cupsUTF8ToUTF32(utf32dest, (cups_utf8_t *)line, 1024);
    if (len < 0)
    {
      printf(" error line: %d (UTF-8 to UTF-32)\n", count);
      continue;
    }
    for (i = 0; i < len; i ++)
    {
      prop = cupsUTF32CharacterProperty(utf32dest[i],
					CUPS_PROP_GENERAL_CATEGORY);
      if (prop < 0)
	printf(" error line: %d (Prop - General Category)\n", count);
      prop = cupsUTF32CharacterProperty(utf32dest[i],
					CUPS_PROP_BIDI_CATEGORY);
      if (prop < 0)
	printf(" error line: %d (Prop - Bidi Category)\n", count);
      prop = cupsUTF32CharacterProperty(utf32dest[i],
					CUPS_PROP_COMBINING_CLASS);
      if (prop < 0)
	printf(" error line: %d (Prop - Combining Class)\n", count);
      prop = cupsUTF32CharacterProperty(utf32dest[i],
					CUPS_PROP_BREAK_CLASS);
      if (prop < 0)
	printf(" error line: %d (Prop - Break Class)\n", count);
    }
  }
  fclose(fp);
  if (verbose)
    printf(" total lines: %d\n", count);

 /*
  * Test UTF-8 normalization NFKD...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 normalization NFKD...\n");
  len = cupsUTF16ToUTF8(utf8dest, utf16src, 1024);
  if (len < 0)
    return (1);
  strcpy((char *) utf8src, (char *) utf8dest);
  len = cupsUTF8Normalize(utf8dest, utf8src, 1024, CUPS_NORM_NFKD);
  if (len < 0)
    return (1);
  len = cupsUTF8ToUTF16(utf16dest, utf8dest, 1024);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf16(" utf16src ", utf16src);
    print_utf16(" utf16dest", utf16dest);
  }

 /*
  * Test UTF-8 normalization NFD...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 normalization NFD...\n");
  len = cupsUTF8Normalize(utf8dest, utf8src, 1024, CUPS_NORM_NFD);
  if (len < 0)
    return (1);
  len = cupsUTF8ToUTF16(utf16dest, utf8dest, 1024);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf16(" utf16src ", utf16src);
    print_utf16(" utf16dest", utf16dest);
  }

 /*
  * Test UTF-8 normalization NFC...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 normalization NFC...\n");
  len = cupsUTF8Normalize(utf8dest, utf8src, 1024, CUPS_NORM_NFC);
  if (len < 0)
    return (1);
  len = cupsUTF8ToUTF16(utf16dest, utf8dest, 1024);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf16(" utf16src ", utf16src);
    print_utf16(" utf16dest", utf16dest);
  }

 /*
  * Test UTF-8 simple case folding...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 simple case folding...\n");
  len = cupsUTF8CaseFold(utf8dest, utf8src, 1024, CUPS_FOLD_SIMPLE);
  if (len < 0)
    return (1);
  len = cupsUTF8ToUTF16(utf16dest, utf8dest, 1024);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf16(" utf16src ", utf16src);
    print_utf16(" utf16dest", utf16dest);
  }

 /*
  * Test UTF-8 full case folding...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 full case folding...\n");
  len = cupsUTF8CaseFold(utf8dest, utf8src, 1024, CUPS_FOLD_FULL);
  if (len < 0)
    return (1);
  len = cupsUTF8ToUTF16(utf16dest, utf8dest, 1024);
  if (len < 0)
    return (1);
  if (verbose)
  {
    print_utf16(" utf16src ", utf16src);
    print_utf16(" utf16dest", utf16dest);
  }

 /*
  * Test UTF-8 caseless comparison...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 caseless comparison..\n");
  diff = cupsUTF8CompareCaseless(utf8src, utf8dest);
  if (verbose)
    printf(" diff: %d\n", diff);
  if (verbose)
    printf("\ntesti18n: Testing UTF-8 identifier comparison..\n");
  diff = cupsUTF8CompareIdentifier(utf8src, utf8dest);
  if (verbose)
    printf(" diff: %d\n", diff);

 /*
  * Test UTF-32 character properties...
  */
  if (verbose)
    printf("\ntesti18n: Testing UTF-32 character properties..\n");
  utf32char = 0x02B0;
  prop = cupsUTF32CharacterProperty (utf32char,
    CUPS_PROP_GENERAL_CATEGORY);
  if (verbose)
    printf(" utf32char: %04lx  general category %d\n", utf32char, prop);
  utf32char = 0x0621;
  prop = cupsUTF32CharacterProperty (utf32char,
    CUPS_PROP_BIDI_CATEGORY);
  if (verbose)
    printf(" utf32char: %04lx  bidi category	%d\n", utf32char, prop);
  utf32char = 0x0308;
  prop = cupsUTF32CharacterProperty (utf32char,
    CUPS_PROP_COMBINING_CLASS);
  if (verbose)
    printf(" utf32char: %04lx  combining class	%d\n", utf32char, prop);
  utf32char = 0x0009;
  prop = cupsUTF32CharacterProperty (utf32char,
    CUPS_PROP_BREAK_CLASS);
  if (verbose)
    printf(" utf32char: %04lx  break class	%d\n", utf32char, prop);

 /*
  * Test cupsNormalizeMapsFlush()...
  */
  if (verbose)
    printf("\ntesti18n: Testing cupsNormalizeMapsFlush()...\n");
  cupsNormalizeMapsFlush();
  return (0);
}


/*
 * End of "$Id: testi18n.c 5195 2006-02-27 21:05:46Z mike $"
 */