toUpper Localization Problem
-
Hi,
I have been developing a Turkish text mining application with Qt on Windows 7 Professional. I have been using Qt version 5.5.0 for Desktop (MinGW 32bit). In Turkish, the uppercase of character i is I. When I run the following sample code, the function toUpper does not operate properly. What can the reason of this problem be? Can it be Qt bug or Qt compiled with missing feature?QTextCodec *codec = QTextCodec::codecForName("ISO 8859-9"); QTextCodec::setCodecForLocale(codec); QLocale locale(QLocale::Turkish, QLocale::Turkey); QLocale::setDefault(locale); QString str = QString::fromUtf8("İSMAİL"); QString lowerString = str.toLower(); /* ismail CORRECT */ QString str2 = QString::fromUtf8("ismail"); QString upperString = str2.toUpper(); /* ISMAIL WRONG */
Best regards,
-
Hi,
You're using the wrong lower cased i. Unless I'm mistaken, the one you are looking for is U+0069
-
Thanks SGaint, I've read a lot of documents related to Turkish I problem. Turkish lowercase i charecter code is \u0069 according to "Dotted and dotless I" Wikipedia document. You are right. I've tested following code but it produces I characher as result.
QTextCodec *codec = QTextCodec::codecForName("ISO 8859-9"); QTextCodec::setCodecForLocale(codec); QLocale locale(QLocale::Turkish, QLocale::Turkey); QLocale::setDefault(locale); QString iChar = QString::fromUtf8("\u0069"); QString iUpper = iChar.toUpper(); /* RESULT is I */
That document says "unless specifically set up for Turkish, it lowercases I to i and uppercases i to I... Dotless i (and dotted capital I) is handled problematically in the Turkish locales of several software packages,..". If possible I want to learn whether Qt solves that problem. Otherwise where am I doing wrong
Thanks a lot
-
Qt's using a table autogenerated from the Unicode 7.0 database so their might be something there to look at.
-
Hi,
I couldn't do it also. But it should be a simple thing. Did you make it , yaseminyilmaz? -
In the below , my example code is converting Turkish text into lower case and writing a file. But in file "I" is converted to "i".
#include <QCoreApplication> #include <QDebug> #include <QLocale> #include <QTextCodec> #include <QFile> #include <QTextStream> QString convertionTest(QString str) { QTextCodec *codec = QTextCodec::codecForName("ISO 8859-9"); QLocale locale(QLocale::Turkish, QLocale::Turkey); QLocale::setDefault(locale); QString iLower = str.toLower(); /* RESULT is I */ return iLower; } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QFile file; QTextCodec *codec = QTextCodec::codecForName("ISO 8859-9"); if(codec == 0) return -1; file.setFileName("test.txt"); if(file.open(QIODevice::WriteOnly) == false) { return -1; } QTextStream stream(&file); stream.setAutoDetectUnicode(false); QLocale locale(QLocale::Turkish, QLocale::Turkey); stream.setLocale(locale); stream << convertionTest("BU BİR TEST : KADIKÖY"); stream.flush(); return a.exec(); }
-
Hi,
Is there any solution about this please?...
Regards,
Mucip:)