首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

小弟我已经转换为宽字符了,为何find还返回4

2012-01-12 
我已经转换为宽字符了,为何find还返回4?intnLenCStringstr,msgab我的c nLenMultiByteToWideChar(CP_

我已经转换为宽字符了,为何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);

热点排行