char*转wstring

void char_to_wchar(const char* ch, std::wstring& w_str)
{
wchar_t* wchar;
int len = MultiByteToWideChar(CP_ACP, 0, ch, strlen(ch), NULL, 0);
wchar = new wchar_t[len + 1];
MultiByteToWideChar(CP_ACP, 0, ch, strlen(ch), wchar, len);
wchar[len] = ‘\0’;
w_str = wchar;
delete[]wchar;
}

你可能感兴趣的:(c++)