You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2007/10/01 16:54:49 UTC
svn commit: r580981 - /incubator/stdcxx/trunk/util/locale.cpp
Author: faridz
Date: Mon Oct 1 07:54:49 2007
New Revision: 580981
URL: http://svn.apache.org/viewvc?rev=580981&view=rev
Log:
2007-10-01 Farid Zaripov <fa...@epam.com>
* locale.cpp [_WIN32] (EnumLocales): New function to
enumerate system locales.
(print_locale_names): Obtain list of system locales if
RWSTD_LOCALE_ROOT environment variable is not defined.
Modified:
incubator/stdcxx/trunk/util/locale.cpp
Modified: incubator/stdcxx/trunk/util/locale.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/locale.cpp?rev=580981&r1=580980&r2=580981&view=diff
==============================================================================
--- incubator/stdcxx/trunk/util/locale.cpp (original)
+++ incubator/stdcxx/trunk/util/locale.cpp Mon Oct 1 07:54:49 2007
@@ -2361,6 +2361,38 @@
}
+#ifdef _WIN32
+static BOOL CALLBACK
+EnumLocales (char* locale_id)
+{
+ const LCID lcid = std::strtoul (locale_id, 0, 16);
+
+ char buf [80];
+ const int bufsize = sizeof (buf) / sizeof (*buf);
+
+ std::string name;
+
+ if (GetLocaleInfo (lcid, LOCALE_SENGLANGUAGE, buf, bufsize))
+ name = buf;
+
+ if (GetLocaleInfo (lcid, LOCALE_SENGCOUNTRY, buf, bufsize)) {
+ name += '_';
+ name += buf;
+ }
+
+ if ( GetLocaleInfo (lcid, LOCALE_IDEFAULTANSICODEPAGE , buf, bufsize)
+ && std::strtoul (buf, 0, 10)) {
+ name += '.';
+ name += buf;
+ }
+
+ if (const char* locname = std::setlocale (LC_ALL, name.c_str ()))
+ std::cout << locname << '\n';
+
+ return TRUE;
+}
+#endif
+
// print the available locales
static void
print_locale_names ()
@@ -2373,6 +2405,13 @@
const std::string cmd = std::string (LS_1) + locale_root;
std::system (cmd.c_str ());
+ }
+ else {
+#ifndef _WIN32
+ std::system ("/usr/bin/locale -a");
+#else
+ EnumSystemLocales (EnumLocales, LCID_INSTALLED);
+#endif
}
}