]>
Commit | Line | Data |
---|---|---|
c63b67bd UD |
1 | /* Test case by yaoz@nih.gov. */ |
2 | ||
3 | #include <iconv.h> | |
1bc83d2b | 4 | #include <stddef.h> |
c63b67bd UD |
5 | #include <stdio.h> |
6 | #include <string.h> | |
7 | ||
29955b5d AS |
8 | static int |
9 | do_test (void) | |
c63b67bd UD |
10 | { |
11 | char utf8[5]; | |
12 | wchar_t ucs4[5]; | |
13 | iconv_t cd; | |
5748f418 | 14 | char *inbuf; |
c63b67bd UD |
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; | |
c63b67bd | 33 | outbytes = 4 * sizeof (wchar_t); /* "Argument list too long" error. */ |
c63b67bd UD |
34 | n = iconv (cd, &inbuf, &inbytes, &outbuf, &outbytes); |
35 | if (n == (size_t) -1) | |
36 | { | |
2fad2c60 | 37 | printf ("iconv: %m\n"); |
c63b67bd UD |
38 | iconv_close (cd); |
39 | return 1; | |
40 | } | |
41 | iconv_close (cd); | |
42 | ||
43 | return 0; | |
44 | } | |
29955b5d AS |
45 | |
46 | #define TEST_FUNCTION do_test () | |
47 | #include "../test-skeleton.c" |