como posso converter wstring em u16string?
Eu quero converterwstring
parau16string
em C ++.
Eu posso converterwstring
para string, ou reverter. Mas eu não sei como converter parau16string
.
u16string CTextConverter::convertWstring2U16(wstring str)
{
int iSize;
u16string szDest[256] = {};
memset(szDest, 0, 256);
iSize = WideCharToMultiByte(CP_UTF8, NULL, str.c_str(), -1, NULL, 0,0,0);
WideCharToMultiByte(CP_UTF8, NULL, str.c_str(), -1, szDest, iSize,0,0);
u16string s16 = szDest;
return s16;
}
Erro no WideCharToMultiByte (CP_UTF8, NULL, str.c_str (), -1, szDest, iSize, 0,0); 'sszDest
. Causa deu16string
não pode usar comLPSTR
.
Como posso corrigir esse código?