2 * Copyright (c) 2002-2003, Index Data
3 * See the file LICENSE for details.
5 * $Id: tsticonv.c,v 1.2 2003-05-06 10:07:33 adam Exp $
16 #include <yaz/yaz-util.h>
18 /* some test strings in ISO-8859-1 format */
25 static dconvert(int mandatory, const char *tmpcode)
29 for (i = 0; buf[i]; i++)
33 char *inbuf = (char*) buf[i];
34 size_t inbytesleft = strlen(inbuf);
37 char *outbuf = outbuf0;
38 size_t outbytesleft = sizeof(outbuf0);
40 cd = yaz_iconv_open(tmpcode, "ISO-8859-1");
45 printf ("tsticonv 1\n");
48 r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
49 if (r == (size_t)(-1))
51 int e = yaz_iconv_error(cd);
53 printf ("tsticonv 2 e=%d\n", e);
58 cd = yaz_iconv_open("ISO-8859-1", tmpcode);
63 printf ("tsticonv 3\n");
67 inbytesleft = sizeof(outbuf0) - outbytesleft;
70 outbytesleft = sizeof(outbuf1);
71 r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
72 if (r == (size_t)(-1)) {
73 int e = yaz_iconv_error(cd);
75 printf ("tsticonv 4 e=%d\n", e);
78 if (strlen(buf[i]) == (sizeof(outbuf1) - outbytesleft) &&
79 memcmp(outbuf1, buf[i], strlen(buf[i])))
81 printf ("tsticonv 5\n");
88 int main (int argc, char **argv)
91 dconvert(1, "ISO-8859-1");