I have a problem with encoding when writing XML files via QXmlStreamWriter in windows, how can I resolve it? Using stream.setCodec("UTF-8") or "windows-1251" is not helped.
QFile *file = new QFile(filename);
if (file->open(QIODevice::WriteOnly | QIODevice::Text))
         {
         QXmlStreamWriter stream(file);
         stream.setAutoFormatting(true);
         stream.writeStartDocument();
         stream.writeStartElement("СЕКЦИЯ"); // start root section
            stream.writeStartElement("FIELD");
            stream.writeAttribute("name", "Имя");
            stream.writeAttribute("value", "Иван");
     开发者_如何学JAVA       stream.writeEndElement();
         stream.writeEndElement(); // END СЕКЦИЯ
         file->close();
}
Most likely the interpretation of the string literals in your source file is the problem, not the configuration of the stream writer. Make sure your source file is encoded in UTF-8 and use QString::fromUtf8("Imja") etc. (Imja in cyrillic of course) instead of the implicit literal to QString conversion.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论