I'm using Qt5 along with Visual Studio 2012 and recently wrote a logger class, which basically redirect string streams to the file. The other day I realised that there is no "special" characters support (eg. polish, german, russian).
qDebug() << "Special characters: ąężźćłóĄĘŻĆŁÓ";
Is producing the following output:
Special characters: �꿟����ʯƣ�
I have tried multiple Unicode settings listen in File
-> Advanced Save Options
.
However, there is no option to save the file without the BOM
signature and I think that might be the issue, since when I change the file encoding through the Notepad++ to UTF-8 (without BOM)
, then compile, everything is working fine... unfortunately until I make any changes in the Visual Studio.
I have also tried setting compiler encoding to Unicode:
Is there any solution for Visual Studio to change the encoding to UTF-8 without BOM signature?
Code snippet which writes to file:
file = new QFile;
file->setFileName(fileName);
file->open(QIODevice::Append | QIODevice::Text);
[..]
QTextStream out(file);
out.setCodec("UTF-8");
out << QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss ") << value << "\n";
I've been also trying using value.toUtf8()
.