#include #include #include #include #include int main(int argc, char *argv[]) { // UTF-8 encoded string static const char teststr[] = "\xe3\x81\x93"; // UTF-8 encoded, u8"こ", first letter of Konnichiwa (hello in Japanese) // application QApplication app(argc,argv); // stream QString target; // dummy QXmlStreamWriter stream(&target); // using UTF-16 encoding stream.writeTextElement("1",QString{teststr}); const bool error1 = stream.hasError(); // using UTF-8 encoding stream.writeTextElement("2",QAnyStringView{teststr}); const bool error2 = stream.hasError(); // feedback QLabel label(QStringLiteral("%1 %2").arg(error1).arg(error2)); label.show(); return QApplication::exec(); }