Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix for bug #447 merged from SDL 1.2

  • Loading branch information
slouken committed Jul 4, 2007
1 parent ef4d11f commit 0a28cb55e5dd6e8914e7dbc6c0a3b6284501a64a

File 2 of 4 in 0a28cb5

@@ -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;

0 comments on commit 0a28cb5

Please sign in to comment.