I am losing the capability of printing unicode characters right after instancing a QApplication object.
From the following code and having included all the needed li
2017 UPDATE: This answer from 2011 applies for Qt 4. In Qt 5, the text codecs were eliminated, and all source is expected to be UTF-8. See "Source code must be UTF-8 and QString wants it"
When Qt interprets char *
into a string, it uses a text codec. This is set globally, and you can choose what you want for your project:
https://doc.qt.io/qt-4.8/qtextcodec.html#setCodecForCStrings
Note that Qt's default is Latin-1, and it may establish that default in the QApplication constructor call stack somewhere. If you're globally using UTF-8 in your project, you might try:
int main(int argc, char** argv)
{
qDebug() << "aeiou áéíóú";
QApplication app(argc, argv);
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForCStrings(codec);
qDebug() << "aeiou áéíóú";
return 0;
}
And see if that solves your issue.