如何确定 QString 中的特定字符是字母还是标点符号
How can I find out if a specific character in a QString is a letter or punctuation?
如何确定QString中的特定字符是任何语言的字母还是标点符号?
例如,我想在gâteau.
中找到.
,而不是â
。
尝试
str.at(i).isLetter()
对于 unicode 类 Letter_Uppercase/Smallcase/Titlecase/Modifier/Other,它将返回 true。你可以在这里看到:
http://www.sql-und-xml.de/unicode-database/lu.html
http://www.sql-und-xml.de/unicode-database/ll.html
http://www.sql-und-xml.de/unicode-database/lt.html
http://www.sql-und-xml.de/unicode-database/lm.html
http://www.sql-und-xml.de/unicode-database/lo.html
你可以使用 at() 从 QString 中获取 QChar,QChar 有一个 isLetter() 函数。 因此,您需要类似以下内容:
QString myString;
if (myString.at(3).isLetter()) {
qDebug() << "letter number 4 in the string is a letter";
}
相关文章:
- C++字符*缓冲区的大小
- HEX值到wchar_t字符(UTF-8)的转换
- 为什么 Serial.println(<char[]>);返回随机字符?
- 我的字符计数代码计算错误.为什么
- 字符串-C++后显示的随机字符
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 如何在C++中从字符串中分割字符
- 为什么msgrcv()将垃圾字符馈送到缓冲区
- 指向指向字符数组的指针数组的指针
- 如何用转义符替换字符串中的所有特殊字符
- 为什么 sscanf 无法从一个字符串中读取uint64_t和字符?
- 比较字符数组
- 将字符指针十六进制转换为字符串并保存在文本文件C++中
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 如何使用Crypto++并为RSA返回可打印的字节/字符数组
- 如何使用嵌套的getline()函数来获取字符串中的特殊字符和标点符号
- 在字符串的最后一个字符中搜索标点符号
- 如何确定 QString 中的特定字符是字母还是标点符号
- 从字符数组中删除空白和标点符号的函数
- 编写一个程序,读取一串包含标点符号的字符,并写入被读取的内容,但删除了标点符号