我已经转换为宽字符了,为何find还返回4?
int nLen;
CString str,msg = "ab我的c ";
nLen = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,msg,-1,NULL,0) - 1;//6
nLen = msg.Find( "的 ");
str.Format( "%d ",nLen);
AfxMessageBox(str);
我已经转换为宽字符了,为何find还返回4?
[解决办法]
还没有转化为宽字符。
wchar_t wChar[50];
memset(wChar, 0, sizeof(wChar));
nLen = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,msg,-1,NULL,0); //得到宽字节的长度
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,msg,-1,wChar,nlen);