Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=3661572
By: michaelis
I think the most gnuwin32 tools will ignore LC_... environment variables because
they utilise the windows xp native setlocale() function. To substantiate my
assumption, I wrote a small program in C:
int main(void) {
printf("%s\n", setlocale( LC_ALL, NULL ));
setlocale( LC_ALL, "");
printf("%s\n", setlocale( LC_ALL, NULL ));
return 0;
}
The output of the program was
C
German_Switzerland.1252
-- independent on LC_ALL! Now, the first thing that happens within sort.c is:
setlocale( LC_ALL, "");
Thus, on my computer sort.exe will work always with the German_Switzerland.1252
locale.
I propose to apply a patch to all gnuwin32 programs that replace the line
setlocale( LC_ALL, "");
by something more meaningful, e.g. by
{
static struct {int id; char const * name;} const locale_list[] = {
{LC_ALL, "LC_ALL"},
{LC_COLLATE, "LC_COLLATE"},
{LC_CTYPE, "LC_CTYPE"},
{LC_MONETARY, "LC_MONETARY"},
{LC_NUMERIC, "LC_NUMERIC"},
{LC_TIME, "LC_TIME"}
};
int index;
for (
index = 0;
index = sizeof locale_list / sizeof locale_list[0];
index += 1
) {
char const * env_var_name = locale_list[index].name;
char const * env_var_content = getenv(env_var_name);
if (env_var_content != NULL) {
setlocale(locale_list[index].id, env_var_content);
}
}
}
I guess that is what happens with the posix setlocale that the gnuwin32
utilities
are expecting to handle with.
With kind regards
Mathias
______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=74807
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
GnuWin32-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gnuwin32-users