c++ 判断字符串只包含字母、数字、汉字

来源:互联网 发布:kali sql注入检测工具 编辑:程序博客网 时间:2024/06/05 09:27

谢谢 http://blog.csdn.net/kepoon/article/details/8502403

bool checkString(const char * iName)

{
bool result = false;
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;
}
0 0