判斷QString中是否有漢字

2021-06-03 07:58:52 字數 415 閱讀 7183

如題,專案中可能遇到此類問題,先寫個馬馬虎虎的解決方法:

第一種方法,逐一取中qstring的字元,進行判斷。

qstring str;

int ncount = str.count();

for(int i = 0 ; i < ncount ; i++)

}

第二種方法,是利用強大的正規表示式進行判斷。

qstring str;

bool b = str.contains(qregexp("[\\x4e00-\\x9fa5]+"));

if(b)

當然str這個物件,是要先有值了,這個值可以從qlineedit,qstanditem等等常用的其物件來。

判斷QString中是否有漢字

如題,專案中可能遇到此類問題,先寫個馬馬虎虎的解決方法 第一種方法,逐一取中qstring的字元,進行判斷。html view plain copy qstring str int ncount str count for int i 0 i ncount i 第二種方法,是利用強大的正規表示式進行...

oracle 判斷值中是否存在漢字

with x as select 2320 fd少df,sr from dual union all select sr from dual union all select heleo sr from dual union all select 年 sr from dual union all s...

判斷輸入是否為漢字

判斷輸入是否為漢字 2008年03月27日 星期四 下午 08 10 列印 128到65535 漢字在unicode中的16進製製碼中在 u4e00 u9fa5 即 一 和 龥 private void button1 click object sender,eventargs e 龥 int 一 ...