64,646
社区成员
发帖
与我相关
我的任务
分享
CString str = "中国万岁123中国万岁";
int i = 0;
int pos[1024];
int cstrlen = strlen(str);
while (i < cstrlen)
{
unsigned char ch = str[i];
if ((int)ch>0xa0)//如果是中文就把汉字占的2位位置放入数组
{
pos[i] = i;
pos[i + 1] = i;
i = i + 2;
}
else
{
i = i + 1;
}
};
int len = 7;//截取长度
CString strleft;
if (pos[len] != pos[len - 1])//可以截取
strleft = str.Left(len);
else
strleft = str.Left(len - 1);