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:
765 bytes
|
Line | |
---|
1 | /* Test case by yaoz@nih.gov. */
|
---|
2 |
|
---|
3 | #include <iconv.h>
|
---|
4 | #include <stddef.h>
|
---|
5 | #include <stdio.h>
|
---|
6 | #include <string.h>
|
---|
7 |
|
---|
8 | int
|
---|
9 | main (void)
|
---|
10 | {
|
---|
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;
|
---|
19 |
|
---|
20 | strcpy (utf8, "abcd");
|
---|
21 |
|
---|
22 | /* From UTF8 to UCS4. */
|
---|
23 | cd = iconv_open ("UCS4", "UTF8");
|
---|
24 | if (cd == (iconv_t) -1)
|
---|
25 | {
|
---|
26 | perror ("iconv_open");
|
---|
27 | return 1;
|
---|
28 | }
|
---|
29 |
|
---|
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)
|
---|
36 | {
|
---|
37 | printf ("iconv: %m\n");
|
---|
38 | iconv_close (cd);
|
---|
39 | return 1;
|
---|
40 | }
|
---|
41 | iconv_close (cd);
|
---|
42 |
|
---|
43 | return 0;
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.