我尝试将wstring转换为unsigned char。 我试过_wtoc,但这不存在。
_wto样式中是否有转换?
谢谢。
答案 0 :(得分:0)
好吧,我现在这样做了:
wstring sThis=L"12";
unsigned int i;
i=_wtoi(sThis.c_str());
unsigned char c=(unsigned char)i;
答案 1 :(得分:-1)
我这样做
wstring wsWideString
UINT uSize = wsWideString.length();
unsigned char * ptrUChar = new unsigned char[uSize+1];
memset(ptrUChar ,'\0',uSize+1);
for(UINT i=0;i<uSize;i++)
{
ptrUChar [i] = wsWideString[i];
}
//when finished
delete [] ptrUChar ;
ptrUChar = NULL;