c++ 判断字符串只包含字母、数字、汉字 bool StringUtils::CheckName(const char * iName){ bool result=false;if(strle

xiaoxiao2021-02-27  379

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

bool StringUtils::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; }

转载请注明原文地址: https://www.6miu.com/read-6204.html

最新回复(0)