将Unicode转换为多字节

sub*_*bbu 5 c++ visual-c++

我有小问题我想将unicode转换为多字节有什么办法

Cri*_*dam 7

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;
}
Run Code Online (Sandbox Code Playgroud)

它应该使用当前的语言环境来转换unicode字符串.对于不属于代码页的字符"?" 正在使用caracter.使用Visual C++ 2005/2008测试.