const std::stringをconst wcharに変換t* string
563 ワード
const std::stringからconst wchar_に変換t* string
c++コード:
const std::string text=「中国語」;
c++コード:
const std::string text=「中国語」;
std::wstring szDst;
{
int len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text.c_str(), -1, NULL, 0);
wchar_t *wszUtf8 = new wchar_t[len + 1];
memset(wszUtf8, 0, len * 2 + 2);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text.c_str(), -1, (LPWSTR)wszUtf8, len);
szDst = wszUtf8;
delete[]wszUtf8;
}
const wchar_t* string result =
szDst.c_str();