QStringLiteral - mingw vs. msvc
-
QString t =QLatin1String("QLatin1String : äöüß@\\~ÄÜÖ\n"); t +=QStringLiteral( "QStringLiteral : äöüß@\\~ÄÜÖ\n"); t +=QStringLiteral( u"QStringLiteral(u): äöüß@\\~ÄÜÖ\n"); t +=QString( "QString : äöüß@\\~ÄÜÖ\n"); ui->textEdit->setText(t);
Hi all - from the beginning I had the impression, that I do not understand this QStringLiteral thing ... now I found out that this little piece of code gives different result for mingw and msvc build (on Windows, both 64 bit builds in Qt Creator 4.13.0
Based on Qt 5.15.0 (MSVC 2019, 64 bit)).
MinGw looks actually OK (see below) but with msvc only the last line looks OK - all others look like the first one. Can someone explain? -
@JohanSolo : This is the right track! I found this historic post in a german qt forum which proposes to use a /utf8 switch on the compiler. It is actually /utf-8 - but it works like a charm!
I learned that one can put compiler options into the .pro file like this:... QMAKE_CXXFLAGS = /utf-8 ...
So: problem solved!
One more note: I think I did not notice this before because my PC was configured with german as the UI / explorer / shell language and I changed to english a while ago. I guess this made a difference, too (besides switching from mingw to msvc