小编use*_*291的帖子

使用locale时C++ boost崩溃

我正在尝试使用boost库为我的字符串类提供i18支持.我使用的是Microsoft Visual Studio编译器VC10和64位Windows 7机器.

我能够使用boost库编译和链接我的应用程序,但是我的应用程序在调用boost :: locale :: to_upper()时崩溃了.

以下是我写的代码.

#include <boost/locale.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/system/config.hpp>



 String::MakeUpper()()
    {
    boost::locale::generator gen;
    std::locale loc = gen("");
    std::locale::global(loc);
    std::string str2 = boost::locale::to_upper("001Öä", loc); // application crashes here.
    std::string str3 = boost::locale::to_upper("001Öä"); // This also does not work
    }
Run Code Online (Sandbox Code Playgroud)

崩溃发生在以下函数中.此函数抛出错误的强制转换异常.

template<class _Facet> inline
const _Facet& __CRTDECL use_facet(const locale& _Loc)

{   // get facet reference from locale
_BEGIN_LOCK(_LOCK_LOCALE)   // the thread lock, make get atomic
    const locale::facet *_Psave =
        _Facetptr<_Facet>::_Psave;  // static pointer to lazy …
Run Code Online (Sandbox Code Playgroud)

c++ crash boost locale

5
推荐指数
1
解决办法
2463
查看次数

标签 统计

boost ×1

c++ ×1

crash ×1

locale ×1