我有一个小问题,我想将 unicode 转换为多字节有什么办法
I have smalll problem i want to convert unicode into Multi byte is there any way
std::string NarrowString(const std::wstring& str, const char* localeName = "C")
{
std::string result;
result.resize(str.size());
std::locale loc(localeName);
std::use_facet<std::ctype<wchar_t> >(loc).narrow(
str.c_str(), str.c_str() + str.size(), '?', &*result.begin());
return result;
}
它应该使用当前的语言环境来转换 unicode 字符串.对于不属于代码页的字符,'?'正在使用字符.使用 Visual C++ 2005/2008 测试.
It should use the current locale to convert the unicode string. For the caracters that do not belong in the codepage the '?' caracter is being used. Tested with Visual C++ 2005/2008.
这篇关于将 Unicode 转换为多字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!