Last change
on this file was 2036, checked in by bird, 20 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.1 KB
|
Line | |
---|
1 | /* Contributed by Owen Taylor <otaylor@redhat.com>. */
|
---|
2 |
|
---|
3 | #include <iconv.h>
|
---|
4 | #include <errno.h>
|
---|
5 | #include <stddef.h>
|
---|
6 | #include <stdio.h>
|
---|
7 |
|
---|
8 | #define BUFSIZE 10000
|
---|
9 |
|
---|
10 | int
|
---|
11 | main (int argc, char *argv[])
|
---|
12 | {
|
---|
13 | char inbuf[BUFSIZE];
|
---|
14 | wchar_t outbuf[BUFSIZE];
|
---|
15 |
|
---|
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;
|
---|
23 |
|
---|
24 | for (i=0; i < BUFSIZE; i++)
|
---|
25 | inbuf[i] = 'a';
|
---|
26 |
|
---|
27 | cd = iconv_open ("UCS-4LE", "UTF-8");
|
---|
28 |
|
---|
29 | inbytes_left = BUFSIZE;
|
---|
30 | outbytes_left = BUFSIZE * 4;
|
---|
31 | inptr = inbuf;
|
---|
32 | outptr = (char *) outbuf;
|
---|
33 |
|
---|
34 | count = iconv (cd, &inptr, &inbytes_left, &outptr, &outbytes_left);
|
---|
35 |
|
---|
36 | if (count < 0)
|
---|
37 | {
|
---|
38 | if (errno == E2BIG)
|
---|
39 | printf ("Received E2BIG\n");
|
---|
40 | else
|
---|
41 | printf ("Received something else\n");
|
---|
42 |
|
---|
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;
|
---|
48 | }
|
---|
49 | else
|
---|
50 | printf ("Succeeded\n");
|
---|
51 |
|
---|
52 | return result;
|
---|
53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.