
----- Original Message ----
From: Beman Dawes <bdawes@acm.org> To: Boost Developers List <boost@lists.boost.org> Sent: Mon, July 18, 2011 12:09:17 AM Subject: [boost] [locale] Documentation correction
The last bullet item on page libs/locale/doc/html/index.html says:
Many standard libraries provide only the C and POSIX locales, thus GCC supports localization only under Linux. On all other platforms, attempting to create locales other than "C" or "POSIX" would fail.
Actually, locale("") works on most platforms, including PC-BSD and Open Solaris, so needs to be added to the above list of locales that do work. Look at the trunk filesystem regression first test, "locale_info", and click on the Pass link to see the output. locale("") is working pretty much across the board, even on the Darwin tests.
I had actually tested this, AFAIR it had thrown both on Solaris with gcc-3.4 and FreeBSD with gcc-4.2 if the current locale (LANG/LC_ALL) was not C (like en_US.UTF-8) but I may recheck (need to get to my virtual machines) Even if locale("") does not throw it does not mean that it does anything useful. For example with gcc-4.5.3/mingw on Windows, this code #include <iostream> #include <locale> #include <locale.h> int main() { try { std::locale l(""); std::cout << "Ok: " << l.name() << std::endl; } catch(std::exception const &e) { std::cerr <<"Error:"<< e.what() << std::endl; } std::cout << "C Locale:"<< setlocale(LC_ALL,"") << std::endl; } Prints Ok: C C Locale:Hebrew_Israel.1255 And behaves like POSIX locale.
Mac OS X is of particular interest because by default locale("") does fall, and the Apple folks have said in the past that they won't fix it. It fails on my Mac mini in the default configuration. Presumably the Darwin regression test machine has something beyond the default configuration.
This is why Boost.Locale exists.
Also, would it be possible to use locales from the Apache library? See http://stdcxx.apache.org/doc/stdlibref/locale.html#Table%C2%A021
I know this library but I have never tested with it. If you know how to switch the standard library by Apache's one you may try to run Boost.Locale's tests and see how it goes. In any case I'd recommend to use ICU as localization backend as even when standard library works well it still provides quite low quality support. See: http://cppcms.sourceforge.net/boost_locale/html/using_localization_backends.... So it is always better to use ICU unless you want to keep as few dependencies as possible and the standard library support suits you. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/