1 /* Test program by Satoru Takabayashi. */
9 main (int argc
, char **argv
)
11 const char in
[] = "\x41\x42\x43\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa";
12 /* valid eucJP string */
13 const char exp
[] = "\x41\x42\x43\x82\xa0\x82\xa2\x82\xa4";
14 size_t outbufsize
= 10;
15 /* 10 is too small to store full result (intentional) */
16 size_t inleft
, outleft
;
17 char *in_p
= (char *) in
;
26 cd
= iconv_open ("SJIS", "eucJP");
27 if (cd
== (iconv_t
) -1)
29 puts ("iconv_open failed");
33 iconv (cd
, &in_p
, &inleft
, &out_p
, &outleft
); /* this returns E2BIG */
34 for (i
= 0; i
< outbufsize
- outleft
; ++i
)
35 printf (" %02x", (unsigned char) out
[i
]);
39 return outbufsize
- outleft
!= 9 || memcmp (out
, exp
, 9) != 0;