1998-12-09 09:19:36 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-12-09 09:19:36 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1998-12-09 09:19:36 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-12-09 09:19:36 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
1999-02-24 07:37:18 +00:00
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2004-03-06 03:38:59 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
#include "gdkx.h"
|
2010-10-15 02:05:51 +00:00
|
|
|
#include "gdkmain.h"
|
2000-03-28 01:24:44 +00:00
|
|
|
#include "gdkinternals.h"
|
2002-04-25 22:29:14 +00:00
|
|
|
#include "gdkdisplay-x11.h"
|
1998-12-09 09:19:36 +00:00
|
|
|
|
2010-10-15 02:05:51 +00:00
|
|
|
#include <locale.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
1998-12-24 19:39:00 +00:00
|
|
|
|
1998-12-17 09:15:45 +00:00
|
|
|
/* If this variable is FALSE, it indicates that we should
|
|
|
|
* avoid trying to use multibyte conversion functions and
|
|
|
|
* assume everything is 1-byte per character
|
|
|
|
*/
|
|
|
|
static gboolean gdk_use_mb;
|
|
|
|
|
2001-10-10 21:54:25 +00:00
|
|
|
void
|
|
|
|
_gdk_x11_initialize_locale (void)
|
1998-12-17 04:20:29 +00:00
|
|
|
{
|
|
|
|
wchar_t result;
|
|
|
|
gchar *current_locale;
|
2001-10-10 21:54:25 +00:00
|
|
|
static char *last_locale = NULL;
|
1998-12-17 04:20:29 +00:00
|
|
|
|
|
|
|
gdk_use_mb = FALSE;
|
|
|
|
|
2001-10-10 21:54:25 +00:00
|
|
|
current_locale = setlocale (LC_ALL, NULL);
|
|
|
|
|
|
|
|
if (last_locale && strcmp (last_locale, current_locale) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_free (last_locale);
|
|
|
|
last_locale = g_strdup (current_locale);
|
|
|
|
|
2006-02-24 12:28:33 +00:00
|
|
|
if (XSupportsLocale ())
|
|
|
|
XSetLocaleModifiers ("");
|
1998-12-17 04:20:29 +00:00
|
|
|
|
|
|
|
if ((strcmp (current_locale, "C")) && (strcmp (current_locale, "POSIX")))
|
|
|
|
{
|
|
|
|
gdk_use_mb = TRUE;
|
|
|
|
|
|
|
|
#ifndef X_LOCALE
|
2001-10-10 21:54:25 +00:00
|
|
|
/* Detect ancient GNU libc, where mb == UTF8. Not useful unless it's
|
1998-12-17 04:20:29 +00:00
|
|
|
* really a UTF8 locale. The below still probably will
|
|
|
|
* screw up on Greek, Cyrillic, etc, encoded as UTF8.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((MB_CUR_MAX == 2) &&
|
|
|
|
(mbstowcs (&result, "\xdd\xa5", 1) > 0) &&
|
|
|
|
result == 0x765)
|
|
|
|
{
|
|
|
|
if ((strlen (current_locale) < 4) ||
|
2002-09-25 07:23:55 +00:00
|
|
|
g_ascii_strcasecmp (current_locale + strlen(current_locale) - 4,
|
|
|
|
"utf8"))
|
1998-12-17 04:20:29 +00:00
|
|
|
gdk_use_mb = FALSE;
|
|
|
|
}
|
|
|
|
#endif /* X_LOCALE */
|
|
|
|
}
|
|
|
|
|
|
|
|
GDK_NOTE (XIM,
|
|
|
|
g_message ("%s multi-byte string functions.",
|
|
|
|
gdk_use_mb ? "Using" : "Not using"));
|
|
|
|
|
2001-10-16 23:28:45 +00:00
|
|
|
return;
|
1998-12-17 04:20:29 +00:00
|
|
|
}
|
|
|
|
|
2001-10-10 21:54:25 +00:00
|
|
|
gchar*
|
|
|
|
gdk_set_locale (void)
|
|
|
|
{
|
|
|
|
if (!setlocale (LC_ALL,""))
|
|
|
|
g_warning ("locale not supported by C library");
|
|
|
|
|
|
|
|
_gdk_x11_initialize_locale ();
|
|
|
|
|
|
|
|
return setlocale (LC_ALL, NULL);
|
|
|
|
}
|