After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 69955 - Incorrect locale behaviour
Incorrect locale behaviour
Status: RESOLVED FIXED
Product: libgnomeui
Classification: Deprecated
Component: general
unspecified
Other other
: Normal critical
: future
Assigned To: Anders Carlsson
Anders Carlsson
Depends on:
Blocks:
 
 
Reported: 2002-01-29 08:56 UTC by Dmitry G. Mastrukov
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dmitry G. Mastrukov 2002-01-29 08:56:15 UTC
I see many "Locale not supported by C library" warnings. Seems following
peace of code in libgnomeui/gnome-ui-init.c in libgnomeui_pre_args_parse
causes them.

---code---
        /* Begin hack to propogate an en_US locale into Gtk+ if LC_CTYPE=C,
so that non-ASCII
           characters will display for as many people as possible. Related
to bug #1979 */
        ctype = setlocale (LC_CTYPE, "");
	g_print("Ctype: %s\n", ctype);

        if (strcmp (ctype, "C") == 0) {
                old_ctype = g_strdup (g_getenv ("LC_CTYPE"));
                gnome_setenv ("LC_CTYPE", "en_US", TRUE);
                ctype_set = TRUE;
        } else {
                ctype_set = FALSE;
	}

        gtk_set_locale ();

        if (ctype_set) {
                if (old_ctype) {
			gnome_setenv ("LC_CTYPE", old_ctype, TRUE);
                        g_free (old_ctype);
                } else {
			gnome_unsetenv ("LC_CTYPE");
		}
        }
        /* End hack */
---code---

On my machine with properly set locale (LANG=ru_RU.KOI8-R) call to
setlocale(LC_CTYPE, NULL) sets ctype variable to C and hack always run.
After call to gtk_set_locale() locale becomes C too.
According to man it's necessary to initialize locale first with call to
setlocale(XXX,"").
There are two possibilities to do so
1. Change ctype=setlocale(LC_CTYPE, NULL) to setlocale(LC_CTYPE,""). I've
made such modification and all warnigs gone.
2. Place gtk_set_locale() before begin of the hack.
Comment 1 Dmitry G. Mastrukov 2002-01-29 09:10:36 UTC
Sorry, in ---code--- first code string should originally look
ctype=setlocale(LC_CTYPE,NULL)
I've pasted my modified version :)
Comment 2 Anders Carlsson 2002-02-11 02:14:17 UTC
I've removed this code altogether since it isn't necessary anymore now
that we have pango and UTF-8.