1 2 #include <iconv.h> 3 #include <stddef.h> 4 #include <stdio.h> 5 #include <string.h> 6 7 static int do_test(void)8do_test (void) 9 { 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; 18 19 strcpy (utf8, "abcd"); 20 21 /* From UTF8 to UCS4. */ 22 cd = iconv_open ("UCS4", "UTF8"); 23 if (cd == (iconv_t) -1) 24 { 25 perror ("iconv_open"); 26 return 1; 27 } 28 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) 35 { 36 printf ("iconv: %m\n"); 37 iconv_close (cd); 38 return 1; 39 } 40 iconv_close (cd); 41 42 return 0; 43 } 44 45 #define TEST_FUNCTION do_test () 46 #include "../test-skeleton.c" 47