X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Ftsticonv.c;h=b98d640c014755a4a44620bfbb56d1456b7f5c0b;hb=9360e7e7d56e77fb1253faa1232c0417cd5d3ee3;hp=da88d7b0fcc39e12334d4861447832c5a0cec5f6;hpb=38d29054baec012561d8a69ade2a55d6bee22c00;p=yaz-moved-to-github.git diff --git a/util/tsticonv.c b/util/tsticonv.c index da88d7b..b98d640 100644 --- a/util/tsticonv.c +++ b/util/tsticonv.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2003, Index Data * See the file LICENSE for details. * - * $Id: tsticonv.c,v 1.1 2003-04-23 20:34:08 adam Exp $ + * $Id: tsticonv.c,v 1.5 2003-06-22 11:48:33 adam Exp $ */ #if HAVE_CONFIG_H @@ -15,19 +15,67 @@ #include +/* some test strings in ISO-8859-1 format */ const char *buf[] = { - "ax" , - "\330", - "eneb\346r", - 0 }; + "ax" , + "\330", + "eneb\346r", + "\xfc", + "\xfb", + "\xfbr", + 0 }; -static dconvert(int mandatory, const char *tmpcode) +/* some test strings in MARC-8 format */ +const char *marc8_strings[] = { + "ax", + "\xa2", /* latin capital letter o with stroke */ + "eneb\xb5r", /* latin small letter ae */ + "\xe8\x75", /* latin small letter u with umlaut */ + "\xe3\x75", /* latin small letter u with circumflex */ + "\xe3\x75r", /* latin small letter u with circumflex */ + 0 +}; + +static void marc8_tst() +{ + int i; + yaz_iconv_t cd; + + cd = yaz_iconv_open("ISO-8859-1", "MARC8"); + for (i = 0; buf[i]; i++) + { + size_t r; + char *inbuf= (char*) marc8_strings[i]; + size_t inbytesleft = strlen(inbuf); + char outbuf0[24]; + char *outbuf = outbuf0; + size_t outbytesleft = sizeof(outbuf0); + + r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (r == (size_t) (-1)) + { + int e = yaz_iconv_error(cd); + + printf ("tsticonv 6 i=%d e=%d\n", i, e); + exit(6); + } + if ((outbuf - outbuf0) != strlen(buf[i]) + || memcmp(outbuf0, buf[i], strlen(buf[i]))) + { + printf ("tsticonv 7 i=%d\n", i); + printf ("buf=%s out=%s\n", buf[i], outbuf0); + exit(7); + } + } + yaz_iconv_close(cd); +} + +static void dconvert(int mandatory, const char *tmpcode) { int i; yaz_iconv_t cd; for (i = 0; buf[i]; i++) { - int j; size_t r; char *inbuf = (char*) buf[i]; size_t inbytesleft = strlen(inbuf); @@ -90,5 +138,6 @@ int main (int argc, char **argv) dconvert(1, "ISO-8859-1"); dconvert(1, "UCS4"); dconvert(0, "CP865"); + marc8_tst(); exit (0); }