Re: Glib/cygwin minor changes



Huang. writes:
 > i also change:
 > glib-2.0.6/glib/libcharset/config.charset
 > @@ -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
charset.

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
WIN32 code. 

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
codepage, "CPxxx").

--tml





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]