Below is a patch to localedef utility to obtain list of system locales
if RWSTD_LOCALE_ROOT environment variable is not defined.
ChangeLog:
* 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.
Index: locale.cpp
===================================================================
--- locale.cpp (revision 579898)
+++ locale.cpp (working copy)
@@ -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 ()
@@ -2374,6 +2406,13 @@
std::system (cmd.c_str ());
}
+ else {
+#ifndef _WIN32
+ std::system ("/usr/bin/locale -a");
+#else
+ EnumSystemLocales (EnumLocales, LCID_INSTALLED);
+#endif
+ }
}
Farid.