diff -ru boost_1_46_0_ref//libs/filesystem/v3/src/path.cpp boost_1_46_0//libs/filesystem/v3/src/path.cpp --- boost_1_46_0_ref//libs/filesystem/v3/src/path.cpp 2010-10-16 15:09:25.000000000 +0200 +++ boost_1_46_0//libs/filesystem/v3/src/path.cpp 2011-03-10 16:45:00.198210999 +0200 @@ -29,12 +29,13 @@ #include #include #include +#include #include #ifdef BOOST_WINDOWS_API # include "windows_file_codecvt.hpp" # include -#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) +#else # include #endif @@ -733,8 +734,17 @@ std::locale default_locale() { -# ifdef BOOST_WINDOWS_API + try { + // Best try use standard library's locale + // support if avalible + return std::locale(""); + } + catch(std::exception const &/*error*/) { + // Not supported, GCC on non-Linux for example + } std::locale global_loc = std::locale(); + +# ifdef BOOST_WINDOWS_API std::locale loc(global_loc, new windows_file_codecvt); return loc; @@ -754,13 +764,39 @@ // cases." http://lists.apple.com/archives/applescript-users/2002/Sep/msg00319.html // // Many thanks to Peter Dimov for digging out the above references! - std::locale global_loc = std::locale(); std::locale loc(global_loc, new boost::filesystem::detail::utf8_codecvt_facet); return loc; # else - // ISO C calls this "the locale-specific native environment": - return std::locale(""); + + // Get default OS encoding + char const *plang = getenv("LC_CTYPE"); + if(!plang) + plang = getenv("LC_ALL"); + if(!plang) + plang = getenv("LANG"); + if(!plang) + return global_loc; + + std::string lang = plang; + size_t charset_start = lang.find('.'); + if(charset_start == std::string::npos) + return global_loc; + charset_start ++; + size_t end_of_charset = lang.find(charset_start,'@'); + std::string encoding = lang.substr(charset_start,end_of_charset - charset_start); + for(size_t i=0;i