2 * Copyright (c) 2002-2003, Index Data
3 * See the file LICENSE for details.
5 * $Id: tsticonv.c,v 1.1 2003-04-23 20:34:08 adam Exp $
16 #include <yaz/yaz-util.h>
24 static dconvert(int mandatory, const char *tmpcode)
28 for (i = 0; buf[i]; i++)
32 char *inbuf = (char*) buf[i];
33 size_t inbytesleft = strlen(inbuf);
36 char *outbuf = outbuf0;
37 size_t outbytesleft = sizeof(outbuf0);
39 cd = yaz_iconv_open(tmpcode, "ISO-8859-1");
44 printf ("tsticonv 1\n");
47 r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
48 if (r == (size_t)(-1))
50 int e = yaz_iconv_error(cd);
52 printf ("tsticonv 2 e=%d\n", e);
57 cd = yaz_iconv_open("ISO-8859-1", tmpcode);
62 printf ("tsticonv 3\n");
66 inbytesleft = sizeof(outbuf0) - outbytesleft;
69 outbytesleft = sizeof(outbuf1);
70 r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
71 if (r == (size_t)(-1)) {
72 int e = yaz_iconv_error(cd);
74 printf ("tsticonv 4 e=%d\n", e);
77 if (strlen(buf[i]) == (sizeof(outbuf1) - outbytesleft) &&
78 memcmp(outbuf1, buf[i], strlen(buf[i])))
80 printf ("tsticonv 5\n");
87 int main (int argc, char **argv)
90 dconvert(1, "ISO-8859-1");