Boost 1.54 x64 on Win 7 64bits and VS2010. Compiling as "Release x64" and running the following code:
#include <boost/locale/conversion.hpp>
std::wstring y = L"NoNseNSE";
std::wstring w = boost::locale::to_lower(y);
throw std::bad_cast
exception. Nothing changes even after adding (as suggested elsewhere):
std::locale mylocale("");
std::locale::global(mylocale);
or changing to_lower(y)
to: to_lower(y, mylocale)
or using std::string
instead of std::wstring
or setting LANG in the environment.
The goal is to convert to lowercase Italian UTF-8 words. I don't have found around problems like this, so I presume it is my machine specific problem or a boost library problem. BTW I have downloaded the precompiled boost library (boost_1_54_0-msvc-10.0-64.exe) from sourceforge. Any idea? Thanks! mario
This exception is thrown when your locale passed to boost::locale::to_lower
(by default std::locale()
, that is a copy of the global locale) does not have a boost::locale::converter
facet installed. See this for the related documentation.
Use a boost::locale::generator
to create the locale instead. (See also the examples linked to by the documentation, for example this one.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With