【发布时间】:2020-07-17 00:27:01
【问题描述】:
我正在尝试将包含以 utf 编码的 txt 文件内容的字符串转换为使用 boost 的 unicode 字符串是 C++ 并在此之后对其进行规范化。不幸的是,我得到了 bad_cast 错误。任何人都可以帮忙吗? 代码:
convert_to_wstring(void *buffer, int length) {
boost::locale::generator g;
g.locale_cache_enabled(true);
std::locale loc = g(boost::locale::util::get_system_locale());
std::string buffer_char = static_cast<char *>(buffer);
std::wstring result = boost::locale::conv::to_utf<wchar_t>(buffer_char, loc);
result = boost::locale::normalize(result);
result = boost::locale::fold_case(result);
return result;
}
【问题讨论】:
标签: c++ boost normalize boost-locale