Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. toUpper Localization Problem
Forum Update on Monday, May 27th 2025

toUpper Localization Problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
qlocaletoupperturkishtext encoding
7 Posts 4 Posters 3.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yaseminyilmaz
    wrote on last edited by yaseminyilmaz
    #1

    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,

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You're using the wrong lower cased i. Unless I'm mistaken, the one you are looking for is U+0069

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yaseminyilmaz
        wrote on last edited by yaseminyilmaz
        #3

        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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Qt's using a table autogenerated from the Unicode 7.0 database so their might be something there to look at.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • CKurduC Offline
            CKurduC Offline
            CKurdu
            wrote on last edited by
            #5

            Hi,
            I couldn't do it also. But it should be a simple thing. Did you make it , yaseminyilmaz?

            You reap what you sow it

            1 Reply Last reply
            0
            • CKurduC Offline
              CKurduC Offline
              CKurdu
              wrote on last edited by
              #6

              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();
              }
              
              
              

              You reap what you sow it

              1 Reply Last reply
              0
              • MucipM Offline
                MucipM Offline
                Mucip
                wrote on last edited by
                #7

                Hi,
                Is there any solution about this please?...
                Regards,
                Mucip:)

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved