+ printf ("tsticonv 11 i=%d e=%d\n", i, e);
+ exit(11);
+ }
+ compare_buffers("tsticonv 11", i,
+ strlen(iso_8859_1_a[i]), iso_8859_1_a[i],
+ outbuf - outbuf0, outbuf0);
+ }
+ yaz_iconv_close(cd);
+}
+
+static void tst_marc8_to_ucs4b()
+{
+ static struct {
+ const unsigned char *marc8_b;
+ int len;
+ const unsigned char *ucs4_b;
+ } ar[] = {
+ {
+ "\033$1" "\x21\x2B\x3B" /* FF1F */ "\033(B" "o",
+ 8, "\x00\x00\xFF\x1F" "\x00\x00\x00o"
+ }, {
+ "\033$1" "\x6F\x77\x29" /* AE0E */ "\x6F\x52\x7C" /* c0F4 */ "\033(B",
+ 8, "\x00\x00\xAE\x0E" "\x00\x00\xC0\xF4",
+ }, {
+ "\033$1"
+ "\x21\x50\x6E" /* UCS 7CFB */
+ "\x21\x51\x31" /* UCS 7D71 */
+ "\x21\x3A\x67" /* UCS 5B89 */
+ "\x21\x33\x22" /* UCS 5168 */
+ "\x21\x33\x53" /* UCS 5206 */
+ "\x21\x44\x2B" /* UCS 6790 */
+ "\033(B",
+ 24, "\x00\x00\x7C\xFB"
+ "\x00\x00\x7D\x71"
+ "\x00\x00\x5B\x89"
+ "\x00\x00\x51\x68"
+ "\x00\x00\x52\x06"
+ "\x00\x00\x67\x90"
+ }, {
+ "\xB0\xB2", /* AYN and oSLASH */
+ 8, "\x00\x00\x02\xBB" "\x00\x00\x00\xF8"
+ }, {
+ "\xF6\x61", /* a underscore */
+ 8, "\x00\x00\x00\x61" "\x00\x00\x03\x32"
+ }, {
+ "\x61\xC2", /* a, phonorecord mark */
+ 8, "\x00\x00\x00\x61" "\x00\x00\x21\x17"
+ },
+ { /* bug #258 */
+ "el" "\xe8" "am\xe8" "an", /* elaman where a is a" */
+ 32,
+ "\x00\x00\x00" "e"
+ "\x00\x00\x00" "l"
+ "\x00\x00\x00" "a"
+ "\x00\x00\x03\x08"
+ "\x00\x00\x00" "m"
+ "\x00\x00\x00" "a"
+ "\x00\x00\x03\x08"
+ "\x00\x00\x00" "n"
+ },
+ { /* bug #260 */
+ "\xe5\xe8\x41",
+ 12, "\x00\x00\x00\x41" "\x00\x00\x03\x04" "\x00\x00\x03\x08"
+ },
+ {
+ 0, 0, 0
+ }
+ };
+ int i;
+ yaz_iconv_t cd;
+
+ cd = yaz_iconv_open("UCS4", "MARC8");
+ if (!cd)
+ {
+ printf ("tsticonv 20 yaz_iconv_open failed\n");
+ exit(20);
+ }
+ for (i = 0; ar[i].len; i++)
+ {
+ size_t r;
+ size_t expect_len = ar[i].len;
+ char *inbuf= (char*) ar[i].marc8_b;
+ size_t inbytesleft = strlen(inbuf);
+ char outbuf0[64];
+ char *outbuf = outbuf0;
+
+ while (inbytesleft)
+ {
+ size_t outbytesleft = outbuf0 + sizeof(outbuf0) - outbuf;
+ if (outbytesleft > 12)
+ outbytesleft = 12;
+ r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+ if (r == (size_t) (-1))
+ {
+ int e = yaz_iconv_error(cd);
+ if (e != YAZ_ICONV_E2BIG)
+ {
+ printf ("tsticonv 21 i=%d e=%d\n", i, e);
+ exit(21);
+ }
+ }
+ else
+ break;