[Qt-interest] Problesm with utf-8 encoded XML and japanese characters
Chris W
qtinterest at psychogeeks.com
Thu Sep 24 04:25:44 CEST 2009
Scott Aron Bloom wrote:
> When I get the QString for the value in question (for the simplified XML)
> QString tmp = doc.firstChildElement().firstChildElement().text();
>
> The japansese characters have been replaced with the ascii
> representation of the text, not the unicode.
I cannot reproduce this (QT 4.5.2 on Linux). I get the Japanese
characters reliably.
* With or without a byte-order-mark in the xml file.
* With text going to a QLabel
* qDebug() output of the string to unicode aware terminal (konsole)
My test harness:
#include <QtGui>
#include <QtXml/QDomDocument>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow mainWin;
QLabel *label = new QLabel;
mainWin.setCentralWidget(label);
QDomDocument doc("mydocument");
QFile file("test.xml");
if (file.open(QIODevice::ReadOnly)) {
if (doc.setContent(&file)) {
qDebug() <<
doc.firstChildElement().firstChildElement().text();
label->setText(
doc.firstChildElement().firstChildElement().text()
);
}
file.close();
}
mainWin.show();
return app.exec();
}
Is it possible to build Qt without Unicode support?
Regards,
Chris W
More information about the Qt-interest-old
mailing list