Skip to content

Commit

Permalink
Fixed bug #349
Browse files Browse the repository at this point in the history
Solaris doesn't support the LATIN1 character set alias.
  • Loading branch information
slouken committed Jul 4, 2007
1 parent 4ee5007 commit b145b53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/SDL_stdinc.h
Expand Up @@ -584,8 +584,8 @@ extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, siz
string that must be freed with SDL_free() or NULL on error.
*/
extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft);
#define SDL_iconv_utf8_ascii(S) SDL_iconv_string("ASCII", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_latin1(S) SDL_iconv_string("LATIN1", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ascii(S) SDL_iconv_string("646", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_latin1(S) SDL_iconv_string("8859-1", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)

Expand Down
2 changes: 2 additions & 0 deletions src/stdlib/SDL_iconv.c
Expand Up @@ -107,9 +107,11 @@ static struct {
const char *name;
int format;
} encodings[] = {
{ "646", ENCODING_ASCII },
{ "ASCII", ENCODING_ASCII },
{ "US-ASCII", ENCODING_ASCII },
{ "LATIN1", ENCODING_LATIN1 },
{ "8859-1", ENCODING_LATIN1 },
{ "ISO-8859-1", ENCODING_LATIN1 },
{ "UTF8", ENCODING_UTF8 },
{ "UTF-8", ENCODING_UTF8 },
Expand Down
10 changes: 7 additions & 3 deletions test/testiconv.c
Expand Up @@ -53,12 +53,16 @@ int main(int argc, char *argv[])
for ( i = 0; i < SDL_arraysize(formats); ++i ) {
test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
if ( SDL_memcmp(test[1], ucs4, len) != 0 ) {
if ( !test[1] || SDL_memcmp(test[1], ucs4, len) != 0 ) {
fprintf(stderr, "FAIL: %s\n", formats[i]);
++errors;
}
SDL_free(test[0]);
SDL_free(test[1]);
if ( test[0] ) {
SDL_free(test[0]);
}
if ( test[1] ) {
SDL_free(test[1]);
}
}
test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len);
SDL_free(ucs4);
Expand Down

0 comments on commit b145b53

Please sign in to comment.