for(int i = 0; i < str.GetLength(); i ++) { char c = str.GetAt(i); if(c < 0x80) { //是中文的一部分 } else { //是英文或符号 } }还是赶快装一个MSDN吧,这是正事
no. you must check buffer bytes by bytes. ms has a API named IsDbcsLeadByte. think you string is in szStrBuffer, end with \0.then char *p = (char *) &szStrBuffer[0]; while ( *p) { if (::IsDbcsLeadByte(*p)) { //... do you work here , it's a double byte char p+=2; }else { //it's a single char p++; } }because isdbcsleadbyte work with Local, you code can run in various os.
我没有安装msdn,麻烦你帮我查查~
{
char c = str.GetAt(i);
if(c < 0x80)
{
//是中文的一部分
}
else
{
//是英文或符号
}
}还是赶快装一个MSDN吧,这是正事
ms has a API named IsDbcsLeadByte. think you string is in szStrBuffer, end with \0.then char *p = (char *) &szStrBuffer[0];
while ( *p)
{
if (::IsDbcsLeadByte(*p))
{
//... do you work here , it's a double byte char
p+=2;
}else
{
//it's a single char
p++;
}
}because isdbcsleadbyte work with Local, you code can run in various os.