Update.
[glibc.git] / iconv / tst-iconv1.c
blobd40fe539ba111217364b598b95a3fa7156dcd789
1 /* Test case by yaoz@nih.gov. */
3 #include <iconv.h>
4 #include <stdio.h>
5 #include <string.h>
7 int
8 main (void)
10 char utf8[5];
11 wchar_t ucs4[5];
12 iconv_t cd;
13 char *inbuf;
14 char *outbuf;
15 size_t inbytes;
16 size_t outbytes;
17 size_t n;
19 strcpy (utf8, "abcd");
21 /* From UTF8 to UCS4. */
22 cd = iconv_open ("UCS4", "UTF8");
23 if (cd == (iconv_t) -1)
25 perror ("iconv_open");
26 return 1;
29 inbuf = utf8;
30 inbytes = 4;
31 outbuf = (char *) ucs4;
32 outbytes = 4 * sizeof (wchar_t); /* "Argument list too long" error. */
33 n = iconv (cd, &inbuf, &inbytes, &outbuf, &outbytes);
34 if (n == (size_t) -1)
36 printf ("iconv: %m\n");
37 iconv_close (cd);
38 return 1;
40 iconv_close (cd);
42 return 0;