summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-15 02:01:41 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2012-10-02 22:16:08 -0700
commitd678ab80b2987ddd696519a27dad5571c379b511 (patch)
tree58edc1ba4455426cf4545bc838aadece8ca8cffd /scope.c
parent95a96dbdc483d9dc6371f52a9e41771a64d23aed (diff)
downloadxscope-d678ab80b2987ddd696519a27dad5571c379b511.tar.gz
Print UTF8_STRING properties as text if locale uses UTF-8 charset
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/scope.c b/scope.c
index c20deba..96f0464 100644
--- a/scope.c
+++ b/scope.c
@@ -68,6 +68,11 @@
#include <netdb.h> /* struct servent * and struct hostent * */
#include <errno.h> /* for EINTR, EADDRINUSE, ... */
+#include <locale.h>
+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif
+
/* ********************************************** */
/* */
@@ -86,7 +91,8 @@ static FD ConnectToClient(FD ConnectionSocket);
static void DataFromClient(FD fd);
static void SetUpStdin(void);
-long TranslateText = 0;
+char TranslateText = 0;
+char IsUTF8locale = 0;
char ScopeEnabled = 1;
char HandleSIGUSR1 = 0;
char DoAudio = 0;
@@ -666,6 +672,21 @@ Usage(void)
}
static void
+InitializeLocale(void)
+{
+ setlocale(LC_CTYPE, "");
+
+#ifdef HAVE_LANGINFO_H
+ {
+ const char *charmap = nl_langinfo (CODESET);
+
+ if (charmap != NULL && strcmp(charmap, "UTF-8") == 0)
+ IsUTF8locale = 1;
+ }
+#endif
+}
+
+static void
ScanArgs(int argc, char **argv)
{
XVerbose = 1; /* default verbose-ness level */
@@ -795,6 +816,7 @@ ScanArgs(int argc, char **argv)
int
main(int argc, char **argv)
{
+ InitializeLocale();
ScanArgs(argc, argv);
InitializeFD();
InitializeX11();