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++中测试通过。
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++中测试通过。
相关文章推荐
- c++ 判断字符串只包含字母、数字、汉字
- c++ 判断字符串只包含字母、数字、汉字
- c++ 判断字符串只包含字母、数字、汉字
- c++ 判断字符串只包含字母、数字、汉字
- c++ 判断字符串只包含字母、数字、汉字 bool StringUtils::CheckName(const char * iName){ bool result=false; if(strle
- java用正则表达式判断字符串中是否仅包含英文字母、数字和汉字
- java用正则表达式判断字符串中是否仅包含英文字母、数字和汉字
- 判断字符串中是否仅包含字母数字和汉字
- 判断字符串中是否仅包含字母数字和汉字
- java用正则表达式判断字符串中是否仅包含英文字母、数字和汉字 分类: Android JAVA 2015-06-07 21:08 31人阅读 评论(0) 收藏
- java用正则表达式判断字符串中是否仅包含英文字母、数字和汉字
- java用正则表达式判断字符串中是否仅包含英文字母、数字和汉字
- java用正则表达式判断字符串中是否仅包含英文字母、数字和汉字
- java用正则表达式判断字符串中是否仅包含英文字母、数字和汉字
- 获取包含中文,字母,数字集合的字符串的长度(1个汉字字符存储需要2个字节,1个英文字符存储需要1个字节)
- Android中判断字符串中必须包含字母或者数字
- VC 判断CString字符串中各位是数字,大小写字母,符号,汉字。(UNICODE和ANSI)
- VC 判断CString字符串中各位是数字,大小写字母,符号,汉字
- 判断字符串是否包含字母、数字、中文
- js判断输入字符串长度(汉字算两个字符,字母数字算一个)