Added a record for testing of bug #1778.
[yaz-moved-to-github.git] / test / tsticonv.c
1 /*
2  * Copyright (C) 1995-2007, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: tsticonv.c,v 1.32 2007-10-15 20:45:05 adam Exp $
6  */
7
8 #if HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11
12 #include <stdlib.h>
13 #include <errno.h>
14 #include <string.h>
15 #include <ctype.h>
16
17 #include <yaz/yaz-util.h>
18 #include <yaz/test.h>
19
20 static int compare_buffers(char *msg, int no,
21                            int expect_len, const char *expect_buf,
22                            int got_len, const char *got_buf)
23 {
24     if (expect_len == got_len
25         && !memcmp(expect_buf, got_buf, expect_len))
26         return 1;
27     
28     if (0) /* use 1 see how the buffers differ (for debug purposes) */
29     {
30         int i;
31         printf("tsticonv test=%s i=%d failed\n", msg, no);
32         printf("off got exp\n");
33         for (i = 0; i<got_len || i<expect_len; i++)
34         {
35             char got_char[10];
36             char expect_char[10];
37             
38             if (i < got_len)
39                 sprintf(got_char, "%02X", got_buf[i]);
40             else
41                 sprintf(got_char, "?  ");
42             
43             if (i < expect_len)
44                 sprintf(expect_char, "%02X", expect_buf[i]);
45             else
46                 sprintf(expect_char, "?  ");
47             
48             printf("%02d  %s  %s %c\n",
49                    i, got_char, expect_char, got_buf[i] == expect_buf[i] ?
50                    ' ' : '*');
51             
52         }
53     }
54     return 0;
55 }
56
57 static int tst_convert_l(yaz_iconv_t cd, size_t in_len, const char *in_buf,
58                          size_t expect_len, const char *expect_buf)
59 {
60     size_t r;
61     char *inbuf= (char*) in_buf;
62     size_t inbytesleft = in_len > 0 ? in_len : strlen(in_buf);
63     char outbuf0[64];
64     char *outbuf = outbuf0;
65
66     while (inbytesleft)
67     {
68         size_t outbytesleft = outbuf0 + sizeof(outbuf0) - outbuf;
69         if (outbytesleft > 12)
70             outbytesleft = 12;
71         r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
72         if (r == (size_t) (-1))
73         {
74             int e = yaz_iconv_error(cd);
75             if (e != YAZ_ICONV_E2BIG)
76                 return 0;
77         }
78         else
79         {
80             yaz_iconv(cd, 0, 0, &outbuf, &outbytesleft);
81             break;
82         }
83     }
84
85     return compare_buffers("tsticonv 22", 0,
86                            expect_len, expect_buf,
87                            outbuf - outbuf0, outbuf0);
88 }
89
90 static int tst_convert(yaz_iconv_t cd, const char *buf, const char *cmpbuf)
91 {
92     int ret = 0;
93     WRBUF b = wrbuf_alloc();
94     char outbuf[12];
95     size_t inbytesleft = strlen(buf);
96     const char *inp = buf;
97     int rounds = 0;
98     for (rounds = 0; inbytesleft && rounds < sizeof(outbuf); rounds++)
99     {
100         size_t outbytesleft = sizeof(outbuf);
101         char *outp = outbuf;
102         size_t r = yaz_iconv(cd, (char**) &inp,  &inbytesleft,
103                              &outp, &outbytesleft);
104         wrbuf_write(b, outbuf, outp - outbuf);
105         if (r == (size_t) (-1))
106         {
107             int e = yaz_iconv_error(cd);
108             if (e != YAZ_ICONV_E2BIG)
109                 break;
110         }
111         else
112         {
113             size_t outbytesleft = sizeof(outbuf);
114             char *outp = outbuf;
115             r = yaz_iconv(cd, 0, 0, &outp, &outbytesleft);
116             wrbuf_write(b, outbuf, outp - outbuf);
117             break;
118         }
119     }
120     if (wrbuf_len(b) == strlen(cmpbuf) 
121         && !memcmp(cmpbuf, wrbuf_buf(b), wrbuf_len(b)))
122         ret = 1;
123     else
124     {
125         WRBUF w = wrbuf_alloc();
126
127         wrbuf_rewind(w);
128         wrbuf_verbose_str(w, buf, strlen(buf));
129         yaz_log(YLOG_LOG, "input %s", wrbuf_cstr(w));
130
131         wrbuf_rewind(w);
132         wrbuf_verbose_str(w, wrbuf_buf(b), wrbuf_len(b));
133         yaz_log(YLOG_LOG, "got %s", wrbuf_cstr(w));
134         
135         wrbuf_rewind(w);
136         wrbuf_verbose_str(w, cmpbuf, strlen(cmpbuf));
137         yaz_log(YLOG_LOG, "exp %s", wrbuf_cstr(w));
138
139         wrbuf_destroy(w);
140     }
141
142     wrbuf_destroy(b);
143     return ret;
144 }
145
146
147 /* some test strings in ISO-8859-1 format */
148 static const char *iso_8859_1_a[] = {
149     "ax" ,
150     "\xd8",
151     "eneb\346r",
152     "\xe5" "\xd8",
153     "\xe5" "\xd8" "b",
154     "\xe5" "\xe5",
155     0 };
156
157 static void tst_marc8_to_ucs4b(void)
158 {
159     yaz_iconv_t cd = yaz_iconv_open("UCS4", "MARC8");
160     YAZ_CHECK(cd);
161     if (!cd)
162         return;
163     
164     YAZ_CHECK(tst_convert_l(
165                   cd,
166                   0,
167                   "\033$1" "\x21\x2B\x3B" /* FF1F */ "\033(B" "o",
168                   8, 
169                   "\x00\x00\xFF\x1F" "\x00\x00\x00o"));
170     YAZ_CHECK(tst_convert_l(
171                   cd,
172                   0,
173                   "\033$1" "\x6F\x77\x29" /* AE0E */
174                   "\x6F\x52\x7C" /* c0F4 */ "\033(B",
175                   8,
176                   "\x00\x00\xAE\x0E" "\x00\x00\xC0\xF4"));
177     YAZ_CHECK(tst_convert_l(
178                   cd,
179                   0,
180                   "\033$1"
181                   "\x21\x50\x6E"  /* UCS 7CFB */
182                   "\x21\x51\x31"  /* UCS 7D71 */
183                   "\x21\x3A\x67"  /* UCS 5B89 */
184                   "\x21\x33\x22"  /* UCS 5168 */
185                   "\x21\x33\x53"  /* UCS 5206 */
186                   "\x21\x44\x2B"  /* UCS 6790 */
187                   "\033(B",
188                   24, 
189                   "\x00\x00\x7C\xFB"
190                   "\x00\x00\x7D\x71"
191                   "\x00\x00\x5B\x89"
192                   "\x00\x00\x51\x68"
193                   "\x00\x00\x52\x06"
194                   "\x00\x00\x67\x90"));
195
196     YAZ_CHECK(tst_convert_l(
197                   cd,
198                   0,
199                   "\xB0\xB2",     /* AYN and oSLASH */
200                   8, 
201                   "\x00\x00\x02\xBB"  "\x00\x00\x00\xF8"));
202     YAZ_CHECK(tst_convert_l(
203                   cd,
204                   0,
205                   "\xF6\x61",     /* a underscore */
206                   8, 
207                   "\x00\x00\x00\x61"  "\x00\x00\x03\x32"));
208
209     YAZ_CHECK(tst_convert_l(
210                   cd,
211                   0,
212                   "\x61\xC2",     /* a, phonorecord mark */
213                   8,
214                   "\x00\x00\x00\x61"  "\x00\x00\x21\x17"));
215
216     /* bug #258 */
217     YAZ_CHECK(tst_convert_l(
218                   cd,
219                   0,
220                   "el" "\xe8" "am\xe8" "an", /* elaman where a is a" */
221                   32,
222                   "\x00\x00\x00" "e"
223                   "\x00\x00\x00" "l"
224                   "\x00\x00\x00" "a"
225                   "\x00\x00\x03\x08"
226                   "\x00\x00\x00" "m"
227                   "\x00\x00\x00" "a"
228                   "\x00\x00\x03\x08"
229                   "\x00\x00\x00" "n"));
230     /* bug #260 */
231     YAZ_CHECK(tst_convert_l(
232                   cd,
233                   0,
234                   "\xe5\xe8\x41",
235                   12, 
236                   "\x00\x00\x00\x41" "\x00\x00\x03\x04" "\x00\x00\x03\x08"));
237     /* bug #416 */
238     YAZ_CHECK(tst_convert_l(
239                   cd,
240                   0,
241                   "\xEB\x74\xEC\x73",
242                   12,
243                   "\x00\x00\x00\x74" "\x00\x00\x03\x61" "\x00\x00\x00\x73"));
244     /* bug #416 */
245     YAZ_CHECK(tst_convert_l(
246                   cd,
247                   0,
248                   "\xFA\x74\xFB\x73",
249                   12, 
250                   "\x00\x00\x00\x74" "\x00\x00\x03\x60" "\x00\x00\x00\x73"));
251
252     yaz_iconv_close(cd);
253 }
254
255 static void tst_ucs4b_to_utf8(void)
256 {
257     yaz_iconv_t cd = yaz_iconv_open("UTF8", "UCS4");
258     YAZ_CHECK(cd);
259     if (!cd)
260         return;
261     YAZ_CHECK(tst_convert_l(
262                   cd,
263                   8,
264                   "\x00\x00\xFF\x1F\x00\x00\x00o",
265                   4,
266                   "\xEF\xBC\x9F\x6F"));
267
268     YAZ_CHECK(tst_convert_l(
269                   cd,
270                   8, 
271                   "\x00\x00\xAE\x0E\x00\x00\xC0\xF4",
272                   6,
273                   "\xEA\xB8\x8E\xEC\x83\xB4"));
274     yaz_iconv_close(cd);
275 }
276
277 static void dconvert(int mandatory, const char *tmpcode)
278 {
279     int i;
280     int ret;
281     yaz_iconv_t cd;
282     for (i = 0; iso_8859_1_a[i]; i++)
283     {
284         size_t r;
285         char *inbuf = (char*) iso_8859_1_a[i];
286         size_t inbytesleft = strlen(inbuf);
287         char outbuf0[24];
288         char outbuf1[10];
289         char *outbuf = outbuf0;
290         size_t outbytesleft = sizeof(outbuf0);
291
292         cd = yaz_iconv_open(tmpcode, "ISO-8859-1");
293         YAZ_CHECK(cd || !mandatory);
294         if (!cd)
295             return;
296         r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
297         YAZ_CHECK(r != (size_t) (-1));
298
299         r = yaz_iconv(cd, 0, 0, &outbuf, &outbytesleft);
300         YAZ_CHECK(r != (size_t) (-1));
301         yaz_iconv_close(cd);
302         if (r == (size_t) (-1))
303             return;
304         
305         cd = yaz_iconv_open("ISO-8859-1", tmpcode);
306         YAZ_CHECK(cd || !mandatory);
307         if (!cd)
308             return;
309         inbuf = outbuf0;
310         inbytesleft = sizeof(outbuf0) - outbytesleft;
311
312         outbuf = outbuf1;
313         outbytesleft = sizeof(outbuf1);
314         r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
315         YAZ_CHECK(r != (size_t) (-1));
316
317         r = yaz_iconv(cd, 0, 0, &outbuf, &outbytesleft);
318         if (r == (size_t)(-1))
319         {
320             fprintf(stderr, "failed\n");
321         }
322         YAZ_CHECK(r != (size_t) (-1));
323
324         if (r != (size_t)(-1)) 
325         {
326             ret = compare_buffers("dconvert", i,
327                                   strlen(iso_8859_1_a[i]), iso_8859_1_a[i],
328                                   sizeof(outbuf1) - outbytesleft, outbuf1);
329             YAZ_CHECK(ret);
330         }
331         yaz_iconv_close(cd);
332     }
333 }
334
335 int utf8_check(unsigned c)
336 {
337     if (sizeof(c) >= 4)
338     {
339         size_t r;
340         char src[4];
341         char dst[4];
342         char utf8buf[6];
343         char *inbuf = src;
344         size_t inbytesleft = 4;
345         char *outbuf = utf8buf;
346         size_t outbytesleft = sizeof(utf8buf);
347         int i;
348         yaz_iconv_t cd = yaz_iconv_open("UTF-8", "UCS4LE");
349         if (!cd)
350             return 0;
351         for (i = 0; i<4; i++)
352             src[i] = c >> (i*8);
353         
354         r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
355         yaz_iconv_close(cd);
356
357         if (r == (size_t)(-1))
358             return 0;
359
360         cd = yaz_iconv_open("UCS4LE", "UTF-8");
361         if (!cd)
362             return 0;
363         inbytesleft = sizeof(utf8buf) - outbytesleft;
364         inbuf = utf8buf;
365
366         outbuf = dst;
367         outbytesleft = 4;
368
369         r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
370         if (r == (size_t)(-1))
371             return 0;
372
373         yaz_iconv_close(cd);
374
375         if (memcmp(src, dst, 4))
376             return 0;
377     }
378     return 1;
379 }
380         
381 static void tst_marc8_to_utf8(void)
382 {
383     yaz_iconv_t cd = yaz_iconv_open("UTF-8", "MARC8");
384
385     YAZ_CHECK(cd);
386     if (!cd)
387         return;
388
389     YAZ_CHECK(tst_convert(cd, "Cours de math", 
390                           "Cours de math"));
391     /* COMBINING ACUTE ACCENT */
392     YAZ_CHECK(tst_convert(cd, "Cours de mathâe", 
393                           "Cours de mathe\xcc\x81"));
394
395
396     YAZ_CHECK(tst_convert(cd, "a\xea\x1e", "a\x1e\xcc\x8a"));
397
398     YAZ_CHECK(tst_convert(cd, "a\xea", "a"));
399     yaz_iconv_close(cd);
400 }
401
402 static void tst_marc8s_to_utf8(void)
403 {
404     yaz_iconv_t cd = yaz_iconv_open("UTF-8", "MARC8s");
405
406     YAZ_CHECK(cd);
407     if (!cd)
408         return;
409
410     YAZ_CHECK(tst_convert(cd, "Cours de math", 
411                           "Cours de math"));
412     /* E9: LATIN SMALL LETTER E WITH ACUTE */
413     YAZ_CHECK(tst_convert(cd, "Cours de mathâe", 
414                           "Cours de math\xc3\xa9"));
415
416     yaz_iconv_close(cd);
417 }
418
419
420 static void tst_marc8_to_latin1(void)
421 {
422     yaz_iconv_t cd = yaz_iconv_open("ISO-8859-1", "MARC8");
423
424     YAZ_CHECK(cd);
425     if (!cd)
426         return;
427
428     YAZ_CHECK(tst_convert(cd, "ax", "ax"));
429
430     /* latin capital letter o with stroke */
431     YAZ_CHECK(tst_convert(cd, "\xa2", "\xd8"));
432
433     /* with latin small letter ae */
434     YAZ_CHECK(tst_convert(cd, "eneb\xb5r", "eneb\346r"));
435
436     YAZ_CHECK(tst_convert(cd, "\xea" "a\xa2", "\xe5" "\xd8"));
437
438     YAZ_CHECK(tst_convert(cd, "\xea" "a\xa2" "b", "\xe5" "\xd8" "b"));
439
440     YAZ_CHECK(tst_convert(cd, "\xea" "a"  "\xea" "a", "\xe5" "\xe5"));
441
442     YAZ_CHECK(tst_convert(cd, "Cours de math", 
443                           "Cours de math"));
444     YAZ_CHECK(tst_convert(cd, "Cours de mathâe", 
445                           "Cours de mathé"));
446     YAZ_CHECK(tst_convert(cd, "12345678âe", 
447                           "12345678é"));
448     YAZ_CHECK(tst_convert(cd, "123456789âe", 
449                           "123456789é"));
450     YAZ_CHECK(tst_convert(cd, "1234567890âe", 
451                           "1234567890é"));
452     YAZ_CHECK(tst_convert(cd, "12345678901âe", 
453                           "12345678901é"));
454     YAZ_CHECK(tst_convert(cd, "Cours de mathâem", 
455                           "Cours de mathém"));
456     YAZ_CHECK(tst_convert(cd, "Cours de mathâematiques", 
457                           "Cours de mathématiques"));
458
459     yaz_iconv_close(cd);
460 }
461
462 static void tst_utf8_to_marc8(void)
463 {
464     yaz_iconv_t cd = yaz_iconv_open("MARC8", "UTF-8");
465
466     YAZ_CHECK(cd);
467     if (!cd)
468         return;
469
470     YAZ_CHECK(tst_convert(cd, "Cours ", "Cours "));
471
472     /** Pure ASCII. 11 characters (sizeof(outbuf)-1) */
473     YAZ_CHECK(tst_convert(cd, "Cours de mat", "Cours de mat"));
474
475     /** Pure ASCII. 12 characters (sizeof(outbuf)) */
476     YAZ_CHECK(tst_convert(cd, "Cours de math", "Cours de math"));
477
478     /** Pure ASCII. 13 characters (sizeof(outbuf)+1) */
479     YAZ_CHECK(tst_convert(cd, "Cours de math.", "Cours de math."));
480
481     /** UPPERCASE SCANDINAVIAN O */
482     YAZ_CHECK(tst_convert(cd, "S\xc3\x98", "S\xa2"));
483
484     /** ARING */
485     YAZ_CHECK(tst_convert(cd, "A" "\xCC\x8A", "\xEA" "A"));
486
487     /** A MACRON + UMLAUT, DIAERESIS */
488     YAZ_CHECK(tst_convert(cd, "A" "\xCC\x84" "\xCC\x88",
489                           "\xE5\xE8\x41"));
490     
491     /* Ligature spanning two characters */
492     YAZ_CHECK(tst_convert(cd,
493                           "\x74" "\xCD\xA1" "\x73",  /* UTF-8 */
494                           "\xEB\x74\xEC\x73"));      /* MARC-8 */
495
496     /* Double title spanning two characters */
497     YAZ_CHECK(tst_convert(cd,
498                           "\x74" "\xCD\xA0" "\x73",  /* UTF-8 */
499                           "\xFA\x74\xFB\x73"));      /* MARC-8 */
500
501     /** Ideographic question mark (Unicode FF1F) */
502     YAZ_CHECK(tst_convert(cd,
503                           "\xEF\xBC\x9F" "o",        /* UTF-8 */
504                           "\033$1" "\x21\x2B\x3B" "\033(B" "o" ));
505
506
507     /** Ideographic space per ANSI Z39.64 */
508     YAZ_CHECK(tst_convert(cd,
509                           "\xe3\x80\x80" "o",        /* UTF-8 */
510                           "\033$1" "\x21\x23\x21" "\033(B" "o" ));
511
512     /** Superscript 0 . bug #642 */
513     YAZ_CHECK(tst_convert(cd,
514                           "(\xe2\x81\xb0)",        /* UTF-8 */
515                           "(\033p0\x1bs)"));
516     
517     
518     /** bug #1778 */
519     YAZ_CHECK(tst_convert(cd,
520                           /* offset 0x530 in UTF-8 rec marccol4.u8.marc */
521                           "\xE3\x83\xB3" "\xE3\x82\xBF" 
522                           "\xCC\x84" "\xCC\x84" "\xE3\x83\xBC" /* UTF-8 */,
523                           "\x1B\x24\x31" "\x69\x25\x73"
524                           "\x1B\x28\x42" "\xE5\xE5" "\x1B\x24\x31" 
525                           "\x69\x25\x3F"
526                           "\x69\x21\x3C" "\x1B\x28\x42"));
527  
528     {
529         char *inbuf0 = "\xe2\x81\xb0";
530         char *inbuf = inbuf0;
531         size_t inbytesleft = strlen(inbuf);
532         char outbuf0[64];
533         char *outbuf = outbuf0;
534         size_t outbytesleft = sizeof(outbuf0)-1;
535         size_t r;
536 #if 0
537         int i;
538 #endif
539         r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
540         YAZ_CHECK(r != (size_t) (-1));
541
542 #if 0
543         *outbuf = '\0';  /* so we know when to stop printing */
544         for (i = 0; outbuf0[i]; i++)
545         {
546             int ch = outbuf0[i] & 0xff;
547             yaz_log(YLOG_LOG, "ch%d %02X %c", i, ch, ch >= ' ' ? ch : '?');
548         }
549 #endif
550
551         r = yaz_iconv(cd, 0, 0, &outbuf, &outbytesleft);
552         YAZ_CHECK(r != (size_t) (-1));
553         *outbuf = '\0';  /* for strcmp test below and printing */
554 #if 0
555         for (i = 0; outbuf0[i]; i++)
556         {
557             int ch = outbuf0[i] & 0xff;
558             yaz_log(YLOG_LOG, "ch%d %02X %c", i, ch, ch >= ' ' ? ch : '?');
559         }
560 #endif
561         YAZ_CHECK(strcmp("\033p0\x1bs", outbuf0) == 0);
562     }
563     yaz_iconv_close(cd);
564 }
565
566 static void tst_advance_to_utf8(void)
567 {
568     yaz_iconv_t cd = yaz_iconv_open("utf-8", "advancegreek");
569
570     YAZ_CHECK(cd);
571     if (!cd)
572         return;
573
574     YAZ_CHECK(tst_convert(cd, "Cours ", "Cours "));
575     yaz_iconv_close(cd);
576 }
577
578 static void tst_utf8_to_advance(void)
579 {
580     yaz_iconv_t cd = yaz_iconv_open("advancegreek", "utf-8");
581
582     YAZ_CHECK(cd);
583     if (!cd)
584         return;
585
586     YAZ_CHECK(tst_convert(cd, "Cours ", "Cours "));
587     yaz_iconv_close(cd);
588 }
589
590 static void tst_latin1_to_marc8(void)
591 {
592     yaz_iconv_t cd = yaz_iconv_open("MARC8", "ISO-8859-1");
593
594     YAZ_CHECK(cd);
595     if (!cd)
596         return;
597
598     YAZ_CHECK(tst_convert(cd, "Cours ", "Cours "));
599
600     /** Pure ASCII. 11 characters (sizeof(outbuf)-1) */
601     YAZ_CHECK(tst_convert(cd, "Cours de mat", "Cours de mat"));
602
603     /** Pure ASCII. 12 characters (sizeof(outbuf)) */
604     YAZ_CHECK(tst_convert(cd, "Cours de math", "Cours de math"));
605
606     /** Pure ASCII. 13 characters (sizeof(outbuf)) */
607     YAZ_CHECK(tst_convert(cd, "Cours de math.", "Cours de math."));
608
609     /** D8: UPPERCASE SCANDINAVIAN O */
610     YAZ_CHECK(tst_convert(cd, "S\xd8", "S\xa2"));
611
612     /** E9: LATIN SMALL LETTER E WITH ACUTE */
613     YAZ_CHECK(tst_convert(cd, "Cours de math\xe9", "Cours de mathâe"));
614     YAZ_CHECK(tst_convert(cd, "Cours de math", "Cours de math"
615                   ));
616     YAZ_CHECK(tst_convert(cd, "Cours de mathé", "Cours de mathâe" ));
617     YAZ_CHECK(tst_convert(cd, "12345678é","12345678âe"));
618     YAZ_CHECK(tst_convert(cd, "123456789é", "123456789âe"));
619     YAZ_CHECK(tst_convert(cd, "1234567890é","1234567890âe"));
620     YAZ_CHECK(tst_convert(cd, "12345678901é", "12345678901âe"));
621     YAZ_CHECK(tst_convert(cd, "Cours de mathém", "Cours de mathâem"));
622     YAZ_CHECK(tst_convert(cd, "Cours de mathématiques",
623                           "Cours de mathâematiques"));
624     yaz_iconv_close(cd);
625 }
626
627 static void tst_utf8_codes(void)
628 {
629     YAZ_CHECK(utf8_check(3));
630     YAZ_CHECK(utf8_check(127));
631     YAZ_CHECK(utf8_check(128));
632     YAZ_CHECK(utf8_check(255));
633     YAZ_CHECK(utf8_check(256));
634     YAZ_CHECK(utf8_check(900));
635     YAZ_CHECK(utf8_check(1000));
636     YAZ_CHECK(utf8_check(10000));
637     YAZ_CHECK(utf8_check(100000));
638     YAZ_CHECK(utf8_check(1000000));
639     YAZ_CHECK(utf8_check(10000000));
640     YAZ_CHECK(utf8_check(100000000));
641 }
642
643 int main (int argc, char **argv)
644 {
645     YAZ_CHECK_INIT(argc, argv);
646
647     tst_utf8_codes();
648
649     tst_marc8_to_utf8();
650
651     tst_marc8s_to_utf8();
652
653     tst_marc8_to_latin1();
654
655     tst_advance_to_utf8();
656     tst_utf8_to_advance();
657
658     tst_utf8_to_marc8();
659
660     tst_latin1_to_marc8();
661
662     tst_marc8_to_ucs4b();
663     tst_ucs4b_to_utf8();
664
665     dconvert(1, "UTF-8");
666     dconvert(1, "ISO-8859-1");
667     dconvert(1, "UCS4");
668     dconvert(1, "UCS4LE");
669     dconvert(0, "CP865");
670
671     YAZ_CHECK_TERM;
672 }
673 /*
674  * Local variables:
675  * c-basic-offset: 4
676  * indent-tabs-mode: nil
677  * End:
678  * vim: shiftwidth=4 tabstop=8 expandtab
679  */