Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
5.12.0
-
None
-
Microsoft Visual Studio Community 2017
Version 15.9.5
Description
I am trying to do something like this:
QString str = QStringLiteral("Some international text"); QFile file("C:/Some/File"); file.open(QIODevice::WriteOnly); file.write(str.toUtf8());
I expect the international text to be written UTF-8 encoded. Instead, it gets written in some broken encoding. My source files are UTF-8 without BOM, though I am using the "/utf-8" MSVC command line switch, so the absence of BOM shouldn't matter.
Looking at the implementation of QStringLiteral, the problem seems to be the following:
#define QT_UNICODE_LITERAL(str) u"" str
Changing it to look like this seems to fix the problem.
#define QT_UNICODE_LITERAL(str) u ## str