Fix Fl_X11_System_Driver::utf8locale() that did not work when no locale is set.

Also, minor simplification of Fl_WinAPI_System_Driver::utf8locale().

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11846 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-07-23 04:48:40 +00:00
parent 67213cf0d8
commit 54dcf145fe
2 changed files with 11 additions and 9 deletions

View File

@ -406,10 +406,7 @@ unsigned Fl_WinAPI_System_Driver::utf8fromwc(char* dst, unsigned dstlen, const w
int Fl_WinAPI_System_Driver::utf8locale()
{
static int ret = 2;
if (ret == 2) {
ret = GetACP() == CP_UTF8;
}
static int ret = (GetACP() == CP_UTF8);
return ret;
}

View File

@ -500,11 +500,16 @@ int Fl_X11_System_Driver::filename_list(const char *d, dirent ***list, int (*sor
}
int Fl_X11_System_Driver::utf8locale() {
char *s;
static int ret = ((s = ::getenv("LC_CTYPE")) && *s) ||
((s = ::getenv("LC_ALL")) && *s) ||
((s = ::getenv("LANG")) && *s)
? 1 : 0;
static int ret = 2;
if (ret == 2) {
char* s;
ret = 1; /* assume UTF-8 if no locale */
if (((s = getenv("LC_CTYPE")) && *s) ||
((s = getenv("LC_ALL")) && *s) ||
((s = getenv("LANG")) && *s)) {
ret = (strstr(s,"utf") || strstr(s,"UTF"));
}
}
return ret;
}