[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. 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. Also, would it be possible to use locales from the Apache library? See http://stdcxx.apache.org/doc/stdlibref/locale.html#Table%C2%A021 --Beman

On Jul 17, 2011, at 5:09 PM, Beman Dawes wrote:
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.
Going forward libc++ on Mac OS X (http://libcxx.llvm.org/) will support a vast array of locales, including "". This is based on BSD's xlocale API: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPa... The behavior of "" mimics that of "" passed to newlocale: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPa... Howard

----- Original Message ----
From: Howard Hinnant <howard.hinnant@gmail.com> To: boost@lists.boost.org Sent: Mon, July 18, 2011 12:23:35 AM Subject: Re: [boost] [locale] Documentation correction
On Jul 17, 2011, at 5:09 PM, Beman Dawes wrote:
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.
Going forward libc++ on Mac OS X (http://libcxx.llvm.org/) will support a vast array of locales, including "". This is based on BSD's xlocale API:
Actually it is not BSD's API it is POSIX 2008 API and BSD family of OSes (like FreeBSD) does not support it. Currently only Darwin and Linux support such API (and it is not fully compatible with each other and the standard). BTW GCC's libstdc++ uses Linux's/GNU LibC's newlocale API.
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPa... l
The behavior of "" mimics that of "" passed to newlocale:
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPa... e
Howard
To be honest... I would not be so optimistic about it at all. Collation (strcoll_l/strcoll; strxfrm/strxfrm_l) is broken under under Darwin (even latest) so it would be still limited. Take a look on what Boost.Locale provides over Darwin/Mac OS X - it would be something like this but even less. In any case Boost.Locale provides posix backed that uses this API and you can freely use it on Darwin platform (of course with its limitations) Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/

----- 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/
participants (3)
-
Artyom Beilis
-
Beman Dawes
-
Howard Hinnant