您的位置:首页 > 编程语言 > C语言/C++

c++中判断字符串只包含字母数字汉字的算法

2009-09-03 15:19 579 查看
bool MulTree::CheckName(const char * iName){
bool result=false;
if(strlen(iName)>62)return result;//长度不能超过62个字符
while(*iName)
{
if((*iName)&0x80){
//是汉字
result=true;
iName++;//知道是汉字的话跳过一个字节检测
}
else if((*iName>='a'&&*iName<='z'||*iName>='A'&&*iName<='Z')||((*iName)>='0'&&(*iName)<='9'))
{
result=true;
}
else{
result=false;
break;
}
iName++;
}
return result;
};

在visual c++中测试通过。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐