CString str=”12中 中6中国45世界654CSDN”
怎么样输出
1
2
中
怎么样输出
1
2
中
中
6
中
国
4
5
世
界
6
5
4
C
S
D
N
也就是输入每个字符?
解决方案
15
//#define _UNICODE
#include <afxdisp.h>
#include <tchar.h>
#include <locale.h>
#include <ctype.h>
int main() {
CString str=_T("12中 中6中国45世界654CSDN");
TCHAR c2[3];
int i;
setlocale(LC_ALL,"chs");
#ifdef _UNICODE
c2[1]=0;
for (i=0;i<str.GetLength();i++) {
c2[0]=str[i];
printf("[%S]\n",c2);
}
#else
c2[2]=0;
for (i=0;i<str.GetLength();i++) {
c2[0]=str[i];
if (isleadbyte(c2[0])) {
c2[1]=str[i+1];
i++;
} else {
c2[1]=0;
}
printf("[%s]\n",c2);
}
#endif
return 0;
}
5
这两天刚好回复过相似的。你可以参考这个:
http://bbs.csdn.net/topics/391966724
本人是 3 楼的回复。非 Unicode 使用这个方法,假如你是 Unicode 直接输出每个字符即可。
http://bbs.csdn.net/topics/391966724
本人是 3 楼的回复。非 Unicode 使用这个方法,假如你是 Unicode 直接输出每个字符即可。