How can I find out if a specific character in a QString is a letter or punctuation in any language?
For example I want to find the .
in gâteau.
but not the â
.
How can I find out if a specific character in a QString is a letter or punctuation in any language?
For example I want to find the .
in gâteau.
but not the â
.
Try
str.at(i).isLetter()
It will return true for the unicode classes Letter_Uppercase/Lowercase/Titlecase/Modifier/Other. Which you can see here:
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
You can get a QChar out of a QString using at(), and QChar has a isLetter() function. Thus, you want something like:
QString myString;
if (myString.at(3).isLetter()) {
qDebug() << "letter number 4 in the string is a letter";
}