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. Amharic alphabet is not recognized by Qt Creator and compiled application on Windows

Amharic alphabet is not recognized by Qt Creator and compiled application on Windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 320 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.
  • F Offline
    F Offline
    Felly
    wrote on last edited by Felly
    #1

    Hi Qt Community,

    I've been developing an application with Amharic content using Qt 5.15.2. On Ubuntu Linux and Android the amharic characters are recognised and displayed. However on Windows string literals in the source code are displayed by empty spaces in both Qt creator and running application. What could be the cause, I have tried QString::fromUtf8 and QTextCodec::setCodecForLocale with UTF-8? Is the compiler missing a flag?

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi @Felly, and welcome!

      Ensure that your source code is saved in UTF-8 encoding, and try using Unicode string literals (u8"..."):

      • https://docs.microsoft.com/en-us/cpp/cpp/string-and-character-literals-cpp
      • https://stackoverflow.com/questions/7636797/unicode-string-literals

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      1
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        While all modern compilers/ide manage utf8, what I normally do (and suggest others do) is to write ascii only in the source code and handle the actual strings in Qt translator

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Felly
          wrote on last edited by
          #4

          Hi @JKSH and @VRonin,

          The default file encoding in tools->options->texteditor is UTF-8 with BOM. In addition, if I open the source code in Notepad the Amharic characters are visible but evidently not on Qt Creator. @VRonin I agree with you, I hard coded the string literal with u8"ኢትዮጵያና" to try figure out the cause for the problem and hence was added for this reason. Unfortunately it is still empty space on a qtextedit or on breakpoint during debugging the QString is " ". Interestingly I ran the application in Linux with wine and I can see the Amharic so I suspect this may very well be a Windows issue that is evading me considering I can see Amharic on other applications.

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            As my colleagues already told you - don't use any non-ascii chars. The MSVC compiler is simply stupid and due to the history of windows to not use utf-8 by default all depends somehow on the current codepage set - so it may work with one setting but when you then run it with another codepage all gets screwed up. You can try to tell them that it's an utf-8 encoded source by passing /utf-8 to your compile options.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by JKSH
              #6

              So it turns out that the default Windows font cannot display Amharic characters. You need to switch to a font that can (like Nyala [1])

              All 4 labels below display fine for me on Qt 5.14.1 + MinGW 7.3.0:

              QApplication app(argc, argv);
              app.setFont(QFont("Nyala"));
              
              QLabel l1(u8"ኢትዮጵያና");
              QLabel l2(u8"\u12a2\u1275\u12ee\u1335\u12eb\u1293");
              QLabel l3( QString::fromUtf8(u8"ኢትዮጵያና") );
              QLabel l4( QString::fromUtf8(u8"\u12a2\u1275\u12ee\u1335\u12eb\u1293") );
              

              @Felly said in Amharic alphabet is not recognized by Qt Creator and compiled application on Windows:

              on Windows string literals in the source code are displayed by empty spaces in both Qt creator

              You can set Qt Creator's font in Tools > Options... > Text Editor > Font & Colors

              [1] https://community.adobe.com/t5/type-typography/amharic-ethiopian-anybody/m-p/1116653#M854

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              2

              • Login

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