如何识别是否串QString str="++++--()()"中有中文输入法混入的中文字符?
//提取字符串中的中文字符串
bool XXClass::checkChineseChar(QString &str)
{
int nCount = str.count();
for(int i = 0 ; i < nCount ; i++)
{
QChar cha = str.at(i);
ushort uni = cha.unicode();
if(uni >= 0x4E00 && uni <= 0x9FA5)
{
qDebug()<<"这个字符是中文:"<<uni;
return true
}
}
return false
}
//判断字符串中是否含有中文字符,可以使用强大的正则表达式
QString str;
str.contains(QRegExp("[\\x4e00-\\x9fa5]+")