[英]boost::locale::to_lower throw bad_cast exception
Boost 1.54 x64 on Win 7 64bits and VS2010. 在Win 7 64位和VS2010上提升1.54 x64。 Compiling as "Release x64" and running the following code:
编译为“Release x64”并运行以下代码:
#include <boost/locale/conversion.hpp>
std::wstring y = L"NoNseNSE";
std::wstring w = boost::locale::to_lower(y);
throw std::bad_cast
exception. 抛出
std::bad_cast
异常。 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. 或者将
to_lower(y)
更改为: to_lower(y, mylocale)
或使用std::string
而不是std::wstring
或在环境中设置LANG。
The goal is to convert to lowercase Italian UTF-8 words. 目标是转换为小写意大利语UTF-8字。 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.
顺便说一下,我从sourceforge下载了预编译的boost库(boost_1_54_0-msvc-10.0-64.exe)。 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. 当您的语言环境传递给
boost::locale::to_lower
(默认为std::locale()
,即全局语言环境的副本)没有安装boost::locale::converter
facet时,抛出此异常。 See this for the related documentation. 有关相关文档,请参阅此处。
Use a boost::locale::generator
to create the locale instead. 使用
boost::locale::generator
来创建语言环境。 (See also the examples linked to by the documentation, for example this one .) (另请参阅文档链接的示例,例如此文档。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.