下面是用C写的一个判断汉字的程序:
#include<stdio.h>
int main(void)
{
int i;
//mr:: str[80]的类型不能写成 char,必须加上 unsigned
unsigned char str[80];
puts("input string:");
scanf("%s",str);
for(i=0;i<80&&str[i]!=' ';)
{
if(str[i]>=0xb0&&str[i]<=0xf7&&str[i+1]>=0xa1&&str[i+1]<=0xfe)
{
printf("chinese character
");
i+=2;
}
else
{
printf("other character
");
i++;
}
}
return 0;
}