
________________________________ From: "Thiel, Bjoern" <bjoern.thiel@mpibpc.mpg.de> To: "boost@lists.boost.org" <boost@lists.boost.org> Sent: Wednesday, October 31, 2012 4:07 PM Subject: [boost] [locale] [filesystem] Windows local 8 bit encoding
Hi,
developing platform independent code I really like the convenience functions conv::to_utf, conv::from_utf, and conv::utf_to_utf from locale. Why not add something like conv::local8bit_to_utf and conv::local8bit_from_utf
First of all locale encoding is not constant, for example there are numerous way to change locale by calling C functions setlocale(LC_ALL,"en_US.ISO-8859-1") or setlocale(LC_ALL,"English_USA.1251") you can change it in C++ as std::locale::global(std::locale("en_US.ISO-8859-1")); or std::locale::global(std::locale("English_USA.1251")); Of course under POSIX platform even stuff like setenv("LANG","en_US.ISO-8859-1",1) Right after main() would effectively change the process locale. Some functions will be effected by such changes some other don't, it depends on implementation and other things. Thus the "concept" of the OS locale is quite uncertain and not well defined especially under Microsoft Windows. Using Boost.Locale you can convert to locale encoding of a given std::locale() object generated with Boost.Locale. boost::locale::generator allows to select legacy "ANSI" encoding instead of UTF-8 to be default upon creation of the locale object that corresponds to the system locale. This object you can use with to_utf and from_utf functions.
following the rational from filesystem (path encoding conversions):
[snip]
I can tell that I think that boost.filesystem's approach is too simplistic and tries to use default behavior as default windows encoding under windows making cross platform development harder. So if you want to write cross platform software stick to UTF-8 and on the boundary of Win32 API convert it to Wide API which is the native Windows API and the correct one to use.
Best regards
Bjoern.
Best, Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/