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