
Originally Posted by
toufic.dbouk
if anyone knows how to solve the qDebug() issue please let me know
There is no qDebug() issue, it simply outputs what you tell it to using the default locale encoding for QStrings. If your console, i.e. the place your output appears, does not understand the encoding used then that is not the fault of qDebug.
This example Qt4 program:
#include <QtCore>
int main(int argc, char **argv)
{
QString test
= QString::fromUtf8("\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669");
qDebug() << test;
return 0;
}
#include <QtCore>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QString test = QString::fromUtf8("\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669");
qDebug() << test;
return 0;
}
To copy to clipboard, switch view to plain text mode
Outputs "٠١٢٣٤٥٦٧٨٩" just fine on my UTF-8 enabled Linux console because the the default codec works well.
My US English Windows XP machine is expecting a different encoding and outputs this by default:
Y:\tt>debug\tt.exe
"??????????"
Y:\tt>debug\tt.exe
"??????????"
To copy to clipboard, switch view to plain text mode
where the '?' stands in for a unicode code point that has no equivalent in the Windows 8-bit code page.
The behaviour of the Windows console is variable beast that depends on selected fonts and other settings etc. You can try this... Start a CMD shell, ensure its font is set to "Lucida Console" or "Consolas", execute "chcp 65001", then run your program from the command line and see if the output is better.
Bookmarks