Skip to content

Commit

Permalink
Fix Fl_X11_System_Driver::utf8locale() that did not work when no loca…
Browse files Browse the repository at this point in the history
…le 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
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Jul 23, 2016
1 parent 67213cf commit 54dcf14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
Expand Up @@ -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;
}

Expand Down
15 changes: 10 additions & 5 deletions src/drivers/X11/Fl_X11_System_Driver.cxx
Expand Up @@ -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;
}

Expand Down

0 comments on commit 54dcf14

Please sign in to comment.