summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-01-21 02:33:13 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-02-06 21:17:29 +0100
commit5c0abe47a800dca3faf97b7ec608d86fddab25b6 (patch)
tree99303e7a50c4e2d5ee88f6161523558a38b07098 /src
parent332b260f17547d822567473f6b92ff710cf738a3 (diff)
downloadratpoison-5c0abe47a800dca3faf97b7ec608d86fddab25b6.zip
introduce defaults.utf8_locale
* use nl_langinfo() to detect if locale codeset is UTF-8
Diffstat (limited to 'src')
-rw-r--r--src/data.h1
-rw-r--r--src/main.c23
2 files changed, 21 insertions, 3 deletions
diff --git a/src/data.h b/src/data.h
index 541ca9e..2be9a98 100644
--- a/src/data.h
+++ b/src/data.h
@@ -235,6 +235,7 @@ struct rp_defaults
XFontSet font;
char *font_string;
+ int utf8_locale;
char *fgcolor_string;
char *bgcolor_string;
diff --git a/src/main.c b/src/main.c
index 417fc1a..bbd0e12 100644
--- a/src/main.c
+++ b/src/main.c
@@ -38,6 +38,10 @@
#include "ratpoison.h"
+#ifdef HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+
/* Several systems seem not to have WAIT_ANY defined, so define it if
it isn't. */
#ifndef WAIT_ANY
@@ -169,7 +173,7 @@ strtok_ws (char *s)
if (s)
pointer = s;
-
+
/* skip to first non-whitespace char. */
while (*pointer && isspace (*pointer)) pointer++;
@@ -546,6 +550,12 @@ init_defaults (void)
set_extents_of_fontset (defaults.font);
#endif
+#ifdef HAVE_LANGINFO_CODESET
+ defaults.utf8_locale = !strcmp (nl_langinfo (CODESET), "UTF-8");
+#endif
+ PRINT_DEBUG (("UTF-8 locale detected: %s\n",
+ defaults.utf8_locale ? "yes" : "no"));
+
defaults.fgcolor_string = xstrdup ("black");
defaults.bgcolor_string = xstrdup ("white");
defaults.fwcolor_string = xstrdup ("black");
@@ -582,10 +592,17 @@ main (int argc, char *argv[])
unsigned char interactive = 0;
char *alt_rcfile = NULL;
- myargv = argv;
- setlocale(LC_CTYPE, "");
+ setlocale (LC_CTYPE, "");
+ if (XSupportsLocale ())
+ {
+ if (!XSetLocaleModifiers (""))
+ PRINT_ERROR (("Couldn't set X locale modifiers.\n"));
+ }
+ else
+ PRINT_ERROR (("X doesn't seem to support your locale.\n"));
/* Parse the arguments */
+ myargv = argv;
while (1)
{
int option_index = 0;