I used the editor Notepad 2 (http://www.flos-freeware.ch/notepad2.html) to view the xml-document. There is an item in the file menu to set the encoding to UTF-8. Then I saved the document. The first line says:
<?xml version="1.0" encoding="UTF-8"?>
I used the editor Notepad 2 (http://www.flos-freeware.ch/notepad2.html) to view the xml-document. There is an item in the file menu to set the encoding to UTF-8. Then I saved the document. The first line says:
<?xml version="1.0" encoding="UTF-8"?>
I'm asking about the file encoding, not xml encoding. Try opening the file with other editors and see if you get characters that look like unicode. Also try loading your file into QTextEdit and making sure you convert from Utf8 using QString::fromUtf8(). The minimal app would look a bit like:
Qt Code:
int main(int argc, char **argv){ QTextEdit te; te.setPlainText(contents); te.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
See if that gives you proper russian characters.
Yes, if I load the file into your mini app then QTextEdit shows me the Russian characters
So now try changing your xml so that the russian characters are not contained in attributes. For example instead of:
make:xml Code:
<doc> <tag attr="value"/> </doc>To copy to clipboard, switch view to plain text mode
xml Code:
<doc> <tag> <attr>value</attr> </tag> </doc>To copy to clipboard, switch view to plain text mode
And see if the problem persists.
I wrote a tiny app that has a dialog and two labels. The first label should show the Russian characters as text of a node and the second label should show the characters as value of an attribute. Result: Both texts are not correct.
Could you attach the questionable xml file here? I'd like to take a look at it.
It seems I paid attention on the XML structure too much. If I read the file and assign the pure content to the label (no xml parsing) then the characters are not correctly shown as well.
Could you attach the file here?
Surprisingly I had to change the extension to "txt" to make the upload work.
This seems to work fine for me:
In both cases I receive "Срочное выключение установки задействовано". It might be because for my system local Qt encoding is utf-8. In your case I think you should add a header to the xml file specifying the utf-8 encoding.Qt Code:
#include <QtGui> #include <QtCore> #include <QtXml> #include <QtDebug> int main(int argc, char **argv){ QTextEdit te; QDomDocument doc; qDebug() << doc.setContent(f.readAll()); te.setPlainText(txt.text()); te.append(txt2.attribute("wert")); te.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
According to your include statements you seem to use Qt 4. I had to modify your code to make it compile with my Qt 3 but now it works. Now I have to find out what I did wrong???
Could you show us your non-working code?
Bookmarks