how to convert unicode to printable string in QT stream
I'm writing a stream to a file and stdout, but I'm getting some kind of encoding like this:
\u开发者_运维问答05ea\u05e7\u05dc\u05d9\u05d8 \u05e9\u05e1\u05d9\u05de\u05dc \u05e9\u05d9\u05e0\u05d5\u05d9 \u05d1\u05e1\u05d2\u05e0\u05d5\u05df \u05dc\u05d3\u05e2\u05ea\u05d9 \u05d0\u05dd \u05d0\u05e0\u05d9 \u05d6\u05d5\u05db\u05e8 \u05e0\u05db\u05d5\u05df
How can I convert this to a printable string?
I can't figure out how you are printing the string, but that is just Unicode:
#include <QString>
#include <QFile>
#include <QDebug>
int main(int argc, char **argv)
{
QString s = "\u05ea\u05e7\u05dc\u05d9\u05d8 \u05e9\u05e1\u05d9\u05de\u05dc \u05e9\u05d9\u05e0\u05d5\u05d9 \u05d1\u05e1\u05d2\u05e0\u05d5\u05df \u05dc\u05d3\u05e2\u05ea\u05d9 \u05d0\u05dd \u05d0\u05e0\u05d9 \u05d6\u05d5\u05db\u05e8 \u05e0\u05db\u05d5\u05df";
QFile file1("1.txt");
if (!file1.open(QIODevice::WriteOnly | QIODevice::Text))
return 1;
QTextStream out(&file1);
out << s << "\n";
qDebug() << s;
return 0;
}
If I compile and run it
g++ -lQtCore -I /usr/include/QtCore test.cpp
./a.out
I can see the printable characters both in the console debug output and in the file:
"תקליט שסימל שינוי בסגנון לדעתי אם אני זוכר נכון"
So you are probably doing something wrong or looking in the wrong direction, can you paste your code so we can help you better?
精彩评论