Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Amharic alphabet is not recognized by Qt Creator and compiled application on Windows
Felly last edited by Felly
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?
Hi @Felly, and welcome!
Ensure that your source code is saved in UTF-8 encoding, and try using Unicode string literals (
VRonin last edited by
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
Felly last edited by
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.
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.
So it turns out that the default Windows font cannot display Amharic characters. You need to switch to a font that can (like Nyala )
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") );
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