Fix for bug #447 merged from SDL 1.2

This commit is contained in:
Sam Lantinga
2007-07-04 08:01:04 +00:00
parent c123a18337
commit bdab6824fd
4 changed files with 38 additions and 12 deletions

View File

@@ -773,6 +773,27 @@ SDL_iconv_close(SDL_iconv_t cd)
#endif /* !HAVE_ICONV */
static const char *
getlocale()
{
const char *lang;
lang = SDL_getenv("LC_ALL");
if (!lang) {
lang = SDL_getenv("LC_CTYPE");
}
if (!lang) {
lang = SDL_getenv("LC_MESSAGES");
}
if (!lang) {
lang = SDL_getenv("LANG");
}
if (!lang || SDL_strcmp(lang, "C") == 0) {
lang = "ASCII";
}
return lang;
}
char *
SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf,
size_t inbytesleft)
@@ -784,6 +805,12 @@ SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf,
size_t outbytesleft;
size_t retCode = 0;
if (!fromcode || !*fromcode) {
fromcode = getlocale();
}
if (!tocode || !*tocode) {
tocode = getlocale();
}
cd = SDL_iconv_open(tocode, fromcode);
if (cd == (SDL_iconv_t) - 1) {
return NULL;