33,311
社区成员
发帖
与我相关
我的任务
分享
//coding: utf-8
#include "stdio.h"
int main()
{
const char* str = "ENG汉字测试ddd";
for(int i = 0; str[i]!='\0'; i++)
{
char ch = str[i];
if(ch<0)
{
printf("Y");
i = i+2;
}
else
{
printf("N");
}
}
//Output:NNNYYYYNNN
return 0;
}
当然,对于只有汉字和标准字符,没问题,可是像韩文等其他非标准ASCII编码字符也会输出Y。更为准确全面的做法是转UTF-32然后查表(http://unicode.org/)