summaryrefslogtreecommitdiff
path: root/src/drivers/X11
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-07-23 04:48:40 +0000
committerManolo Gouy <Manolo>2016-07-23 04:48:40 +0000
commit54dcf145feb39f4eb2e9cd78de2ce469acd3e28c (patch)
treeb04fc82b0c3862cd915ec2674cdefdbb5cc30e87 /src/drivers/X11
parent67213cf0d83b09d6a990879b77f250551d91400f (diff)
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
Diffstat (limited to 'src/drivers/X11')
-rw-r--r--src/drivers/X11/Fl_X11_System_Driver.cxx15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/drivers/X11/Fl_X11_System_Driver.cxx b/src/drivers/X11/Fl_X11_System_Driver.cxx
index c64772143..bea584c11 100644
--- a/src/drivers/X11/Fl_X11_System_Driver.cxx
+++ b/src/drivers/X11/Fl_X11_System_Driver.cxx
@@ -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;
}