mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-18 23:12:15 +08:00
* getlocale.c (main): Use setlocale and fetch string from Windows
using GetLocaleInfoW. Explain why.
This commit is contained in:
parent
af7f57b9fb
commit
ca2b906d55
@ -1,3 +1,8 @@
|
|||||||
|
2010-01-25 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* getlocale.c (main): Use setlocale and fetch string from Windows
|
||||||
|
using GetLocaleInfoW. Explain why.
|
||||||
|
|
||||||
2010-01-22 Corinna Vinschen <corinna@vinschen.de>
|
2010-01-22 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* Makefile.in (CYGWIN_BINS): Add getlocale.
|
* Makefile.in (CYGWIN_BINS): Add getlocale.
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <locale.h>
|
||||||
#define WINVER 0x0601
|
#define WINVER 0x0601
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ int main (int argc, char **argv)
|
|||||||
const char *utf = "";
|
const char *utf = "";
|
||||||
char name[32];
|
char name[32];
|
||||||
|
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
|
while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
@ -112,13 +114,15 @@ int main (int argc, char **argv)
|
|||||||
lcid = (sublang << 10) | lang;
|
lcid = (sublang << 10) | lang;
|
||||||
if (getlocale (lcid, name))
|
if (getlocale (lcid, name))
|
||||||
{
|
{
|
||||||
char lang[256];
|
wchar_t lang[256];
|
||||||
char country[256];
|
wchar_t country[256];
|
||||||
char loc[32];
|
char loc[32];
|
||||||
GetLocaleInfo (lcid, LOCALE_SENGLANGUAGE, lang, 256);
|
/* Go figure. Even the English name of a language or
|
||||||
GetLocaleInfo (lcid, LOCALE_SENGCOUNTRY, country, 256);
|
locale might contain native characters. */
|
||||||
|
GetLocaleInfoW (lcid, LOCALE_SENGLANGUAGE, lang, 256);
|
||||||
|
GetLocaleInfoW (lcid, LOCALE_SENGCOUNTRY, country, 256);
|
||||||
stpcpy (stpcpy (loc, name), utf);
|
stpcpy (stpcpy (loc, name), utf);
|
||||||
printf ("%-16s %s (%s)\n", loc, lang, country);
|
printf ("%-16s %ls (%ls)\n", loc, lang, country);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user