10 const char str[] = "ÄäÖöÜüß";
11 const char expected[] = "AEaeOEoeUEuess";
12 char *inptr = (char *) str;
13 size_t inlen = strlen (str) + 1;
15 char *outptr = outbuf;
16 size_t outlen = sizeof (outbuf);
20 if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
22 puts ("setlocale failed");
26 cd = iconv_open ("ANSI_X3.4-1968//TRANSLIT", "ISO-8859-1");
27 if (cd == (iconv_t) -1)
29 puts ("iconv_open failed");
33 n = iconv (cd, &inptr, &inlen, &outptr, &outlen);
37 printf ("iconv() returned error: %m\n");
39 printf ("iconv() returned %zd, expected 7\n", n);
44 puts ("not all input consumed");
47 else if (inptr - str != strlen (str) + 1)
49 printf ("inptr wrong, advanced by %td\n", inptr - str);
52 if (memcmp (outbuf, expected, sizeof (expected)) != 0)
54 printf ("result wrong: \"%.*s\", expected: \"%s\"\n",
55 (int) (sizeof (outbuf) - outlen), outbuf, expected);
58 else if (outlen != sizeof (outbuf) - sizeof (expected))
60 printf ("outlen wrong: %zd, expected %zd\n", outlen,
61 sizeof (outbuf) - 15);
65 printf ("output is \"%s\" which is OK\n", outbuf);