I think this is an encoding problem. You use implicit cast from const char*
to QString
which results in using QString::fromAscii
. If you want to use non-Latin1 encoding here, you need to call QTextCodec::setCodecForCStrings
and set the encoding your source files are saved in. I'd use UTF-8 encoding, so at the initialization of the app should be done like this:
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf-8"));
QRegExp exp = QRegExp("^[a-zA-Z0-9ğüşöçİĞÜŞÖÇ]+$");
qDebug() << exp.exactMatch("İSMAİL"); // <= true
I suggest more clear solution to check if your problem is here. Save your code in UTF-8 encoding and use QString::fromUtf8
to convert your string literals to QString
using UTF-8 explicitly:
QRegExp exp = QRegExp(QString::fromUtf8("^[a-zA-Z0-9ğüşöçİĞÜŞÖÇ]+$"));
qDebug() << exp.exactMatch(QString::fromUtf8("İSMAİL")); // <= true