6 static size_t widelen(char *data
)
9 Uint32
*p
= (Uint32
*)data
;
16 int main(int argc
, char *argv
[])
18 const char * formats
[] = {
42 file
= fopen(argv
[1], "rb");
44 fprintf(stderr
, "Unable to open %s\n", argv
[1]);
48 while ( fgets(buffer
, sizeof(buffer
), file
) ) {
49 /* Convert to UCS-4 */
51 ucs4
= SDL_iconv_string("UCS-4", "UTF-8", buffer
, SDL_strlen(buffer
)+1);
52 len
= (widelen(ucs4
)+1)*4;
53 for ( i
= 0; i
< SDL_arraysize(formats
); ++i
) {
54 test
[0] = SDL_iconv_string(formats
[i
], "UCS-4", ucs4
, len
);
55 test
[1] = SDL_iconv_string("UCS-4", formats
[i
], test
[0], len
);
56 if ( !test
[1] || SDL_memcmp(test
[1], ucs4
, len
) != 0 ) {
57 fprintf(stderr
, "FAIL: %s\n", formats
[i
]);
67 test
[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4
, len
);
69 fputs(test
[0], stdout
);
72 return (errors
? errors
+ 1 : 0);