Hi,
I'm trying to output unicode in a (Win32) console application, without success until now.
I read on a thread that I should use a QTextStream for this. I tried but did not get any output.
Here my code:
int main(int argc, char *argv[])
{
// qStdOut.setCodec("UTF-16");
qStdOut <<
QString("QTextStream: ") << unicodeString <<
QChar('\n');
std::cout << "cout: " << (char*)unicodeString.utf16() << std::endl;
printf("printf: %ls\n", unicodeString.utf16());
return a.exec();
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTextStream qStdOut(stdout, QIODevice::WriteOnly);
// qStdOut.setCodec("UTF-16");
QString unicodeString(QChar(0x9788));
qStdOut << QString("QTextStream: ") << unicodeString << QChar('\n');
std::cout << "cout: " << (char*)unicodeString.utf16() << std::endl;
printf("printf: %ls\n", unicodeString.utf16());
return a.exec();
}
To copy to clipboard, switch view to plain text mode
The output I get is:
The standard cout/printf don't output unicode, and the QTextStream nothing at all... no "QTextStream: ☼"
Is there something I missed?
Bookmarks