summaryrefslogtreecommitdiffstats
path: root/winsup/utils/getlocale.c
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2010-01-25 09:22:12 +0000
committerCorinna Vinschen <corinna@vinschen.de>2010-01-25 09:22:12 +0000
commitca2b906d557f7313ba10cf07738d81d75e8b3b8c (patch)
treed3db7fa8521fdfed52188876b805d592a5800d43 /winsup/utils/getlocale.c
parentaf7f57b9fbe78eb8fa0d834b1ddcdbcc6eb42ece (diff)
downloadcygnal-ca2b906d557f7313ba10cf07738d81d75e8b3b8c.tar.gz
cygnal-ca2b906d557f7313ba10cf07738d81d75e8b3b8c.tar.bz2
cygnal-ca2b906d557f7313ba10cf07738d81d75e8b3b8c.zip
* getlocale.c (main): Use setlocale and fetch string from Windows
using GetLocaleInfoW. Explain why.
Diffstat (limited to 'winsup/utils/getlocale.c')
-rw-r--r--winsup/utils/getlocale.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/winsup/utils/getlocale.c b/winsup/utils/getlocale.c
index 3a601269f..024dee762 100644
--- a/winsup/utils/getlocale.c
+++ b/winsup/utils/getlocale.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <getopt.h>
#include <string.h>
+#include <locale.h>
#define WINVER 0x0601
#include <windows.h>
@@ -83,6 +84,7 @@ int main (int argc, char **argv)
const char *utf = "";
char name[32];
+ setlocale (LC_ALL, "");
while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
switch (opt)
{
@@ -112,13 +114,15 @@ int main (int argc, char **argv)
lcid = (sublang << 10) | lang;
if (getlocale (lcid, name))
{
- char lang[256];
- char country[256];
+ wchar_t lang[256];
+ wchar_t country[256];
char loc[32];
- GetLocaleInfo (lcid, LOCALE_SENGLANGUAGE, lang, 256);
- GetLocaleInfo (lcid, LOCALE_SENGCOUNTRY, country, 256);
+ /* Go figure. Even the English name of a language or
+ locale might contain native characters. */
+ GetLocaleInfoW (lcid, LOCALE_SENGLANGUAGE, lang, 256);
+ GetLocaleInfoW (lcid, LOCALE_SENGCOUNTRY, country, 256);
stpcpy (stpcpy (loc, name), utf);
- printf ("%-16s %s (%s)\n", loc, lang, country);
+ printf ("%-16s %ls (%ls)\n", loc, lang, country);
}
}
return 0;