8 #define UCS_STR "\x4e\x8c" /* EUC-TW 0xa2a2, EUC-JP 0x */
10 static const char *to_code
;
13 xiconv (iconv_t cd
, int out_size
)
16 char *inp
= (char *) UCS_STR
;
17 char *outp
= (char *) euc
;
18 size_t inbytesleft
= strlen (UCS_STR
);
19 size_t outbytesleft
= out_size
;
24 ret
= iconv (cd
, &inp
, &inbytesleft
, &outp
, &outbytesleft
);
25 if (errno
|| ret
== (size_t) -1)
27 fail
= out_size
== 4 || errno
!= E2BIG
;
28 printf ("expected %d (E2BIG), got %d (%m)\n", E2BIG
, errno
);
32 printf ("%s: 0x%02x%02x\n", to_code
, euc
[0], euc
[1]);
42 xiconv_open (const char *code
)
47 if (errno
|| (cd
= iconv_open (to_code
, "UCS-2BE")) == (iconv_t
) -1)
49 puts ("Can't open converter");
62 cd
= xiconv_open ("EUC-TW");
63 result
|= xiconv (cd
, 4) == true;
65 result
|= xiconv (cd
, 1) == true;
69 cd
= xiconv_open ("EUC-JP");
70 result
|= xiconv (cd
, 4) == true;
72 result
|= xiconv (cd
, 1) == true;