我正在尝试将包含以utf编码的txt文件内容的字符串转换为unicode字符串,使用boost并在此之后对其进行规范化。不幸的是,我得到了 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;
}