.
[glibc/history.git] / iconv / tst-iconv3.c
blobf31c8129d7cc6f336ed7e6b0fd6591ab9e34c623
1 /* Contributed by Owen Taylor <otaylor@redhat.com>. */
3 #include <iconv.h>
4 #include <errno.h>
5 #include <stddef.h>
6 #include <stdio.h>
8 #define BUFSIZE 10000
10 int
11 main (int argc, char *argv[])
13 char inbuf[BUFSIZE];
14 wchar_t outbuf[BUFSIZE];
16 iconv_t cd;
17 int i;
18 char *inptr;
19 char *outptr;
20 size_t inbytes_left, outbytes_left;
21 int count;
22 int result = 0;
24 for (i=0; i < BUFSIZE; i++)
25 inbuf[i] = 'a';
27 cd = iconv_open ("UCS-4LE", "UTF-8");
29 inbytes_left = BUFSIZE;
30 outbytes_left = BUFSIZE * 4;
31 inptr = inbuf;
32 outptr = (char *) outbuf;
34 count = iconv (cd, &inptr, &inbytes_left, &outptr, &outbytes_left);
36 if (count < 0)
38 if (errno == E2BIG)
39 printf ("Received E2BIG\n");
40 else
41 printf ("Received something else\n");
43 printf ("inptr change: %td\n", inptr - inbuf);
44 printf ("inlen change: %zd\n", BUFSIZE - inbytes_left);
45 printf ("outptr change: %td\n", outptr - (char *) outbuf);
46 printf ("outlen change: %zd\n", BUFSIZE * 4 - outbytes_left);
47 result = 1;
49 else
50 printf ("Succeeded\n");
52 return result;