From 13be73d9999a7e746d71698826f488002c7523b5 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 4 Jul 2007 04:27:47 +0000 Subject: [PATCH] Fixed bug #349 Solaris doesn't support the LATIN1 character set alias. --HG-- branch : SDL-1.2 extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402405 --- include/SDL_stdinc.h | 4 ++-- src/stdlib/SDL_iconv.c | 2 ++ test/testiconv.c | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 421392d29..9ea72f6c3 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -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) diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index da9313364..03d8d947e 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -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 }, diff --git a/test/testiconv.c b/test/testiconv.c index 012de4542..53415d005 100644 --- a/test/testiconv.c +++ b/test/testiconv.c @@ -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);