我没有.net,不过你可试试
LPTSTR str= "hehe,我爱大米";
int n=WideCharToMultiByte(CP_ACP,0,str,-1,NULL,NULL,NULL,NULL);
n 为字长度+1
VC下
LPCWSTR str= L"hehe,我爱大米";
int n=WideCharToMultiByte(CP_ACP,0,str,-1,NULL,NULL,NULL,NULL);
CString str = "hehe,我爱大米";
int iLength = 0;
for( int i = 0; i < str.GetLength(); )
{
char c = str.GetAt( i );
iLength ++;
if( c >= 0 )
{// 非汉字
i += 1;
}
else
{// 汉字
i += 2;
}
}