From 52c3e5c091bbe8f16df4ffdff8616b444b23281d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 12 Jul 2007 07:47:29 +0000 Subject: [PATCH] Fixed iconv handling on Solaris 11 --- src/stdlib/SDL_iconv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index 498969de1..fa8d9da0f 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -806,6 +806,16 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb size_t retCode = 0; cd = SDL_iconv_open(tocode, fromcode); + if ( cd == (SDL_iconv_t)-1 ) { + /* See if we can recover here (fixes iconv on Solaris 11) */ + if ( !tocode || !*tocode ) { + tocode = "UTF-8"; + } + if ( !fromcode || !*fromcode ) { + tocode = "UTF-8"; + } + cd = SDL_iconv_open(tocode, fromcode); + } if ( cd == (SDL_iconv_t)-1 ) { return NULL; }