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