1 // commit: b7bfb5c3a8330002250f304cb5deb522fa054eae
2 // fix iconv conversions for iso88592-iso885916
9 static char *test_charsets
[] = {
22 char all_codepoints
[256];
26 all_codepoints
[i
] = 255-i
;
28 for (i
=0; test_charsets
[i
]; i
++) {
29 iconv_t there
= iconv_open("UTF-8", test_charsets
[i
]);
30 if (there
== (iconv_t
)-1) continue;
31 iconv_t andback
= iconv_open(test_charsets
[i
], "UTF-8");
32 if (andback
== (iconv_t
)-1) {
38 size_t u8rem
= sizeof u8buf
;
40 &(char *){all_codepoints
}, &(size_t){sizeof all_codepoints
},
41 &(char *){u8buf
}, &u8rem
);
42 size_t u8len
= sizeof u8buf
- u8rem
;
43 int r2
= iconv(andback
,
44 &(char *){u8buf
}, &(size_t){u8len
},
45 &(char *){buf
}, &(size_t){sizeof buf
});
47 if (r1
) t_error("got %d converting from %s\n", r1
, test_charsets
[i
]);
48 if (r2
) t_error("got %d converting back to %s\n", r2
, test_charsets
[i
]);
50 if (memcmp(all_codepoints
, buf
, sizeof buf
)) {
51 t_error("round trip corrupted %s characters\n", test_charsets
[i
]);