[Interest] Unicode code points in Vusual Studio. Output differs from MinGW

Mark Gaiser markg85 at gmail.com
Thu Aug 11 11:40:46 CEST 2016


Hi,

The following minimal code example demonstrates the issue (tested on Qt
5.6.1):

#include <QDebug>
#include <iostream>
#include <string>

int main(int, char **)
{
  qDebug() << "tr:" << QObject::tr("Co\u00F6rdinaat");
  qDebug() << "QString:" << QString("Co\u00F6rdinaat");
  qDebug() << "(QDebug) std::string:" <<
QString::fromStdString(std::string("Co\u00F6rdinaat"));
  std::cout << "(cout) std::string: " << std::string("Co\u00F6rdinaat") <<
std::endl;

  return 0;
}

Here all the qDebug lines output "Co?rdinaat". The cout line outputs
"Coördinaat" as i would expect.
If i use visual studio (both 2010 and 2015) for the above example, only the
std::cout gives the output i'd expect (which is "Coördinaat").
If i use mingw the exact opposite is the result. All qDebug lines output
"Coördinaat", but the cout line outputs as "Coördinaat"

QStringLiteral("Co\u00F6rdinaat") works on MSVC (2010 and 2015) as well as
MinGW. But for my case that fix isn't working because the string must be
within tr(...) and that function doesn't accept a QStringLiteral.

Is there any way that i can use a string with unicode code points within
tr(...) that works on MSVC 2010 (as that is my setup), but it would be
great if it also works under MSVC 2015 and MinGW.

Best regards,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160811/8dca9259/attachment.html>


More information about the Interest mailing list