Re: Glib/cygwin minor changes
- From: Tor Lillqvist <tml iki fi>
- To: "Huang." <hzhr 21cn com>
- Cc: Stefan Ondrejicka <ondrej idata sk>, gtk-devel-list gnome org
- Subject: Re: Glib/cygwin minor changes
- Date: Thu, 7 Nov 2002 01:15:54 +0000
> i also change:
> @@ -300,7 +300,7 @@
> # BeOS has a single locale, and it has UTF-8 encoding.
> echo "* UTF-8"
> - msdosdjgpp*)
> + msdosdjgpp*|cygwin*)
Note that the charset.alias file (that config.charset writes) gets
used (in localcharset.c:_g_locale_get_charset_aliases()) only unless
WIN32 is defined. In the non-WIN32 case the _g_locale_charset()
function determines the locale from getenv("LC_ALL"), getenv
("LC_CTYPE") or getenv ("LANG"). This locale is then translated into a
charset using the charset.alias file.
The WIN32 code uses sprintf (buf, "CP%u", GetACP ()) to get the local
If you change config.charset like that, and use the non-WIN32 code in
localcharset.c, the charset.alias file maps the locale (if valid) into
one of the CP%d charsets. So, the end result is the same as using the
The mapping works only if your locale is one of those listed in
config.charset. Otherwise _g_locale_charset() returns the locale (!)
as set by the user in an environment variable, which presumably will
cause all kinds of problems higher levels. The user might misguidedly
set LANG to something like "finnish", which is not a charset name
understood by iconv().
Thus, I think it would be simpler to just make sure that a Cygwin
compilation defines WIN32 when compiling localcharset.c. Then
_g_locale_charset() would always return a valid charset name (the
] [Thread Prev