<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QXmlStreamReader Codec]]></title><description><![CDATA[<p dir="auto">Noob question here:<br />
Does QXmlStreamReader auto detect the text codec based on the start document (<code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</code>)? I noticed there is no <code>setCodec</code> method while QXmlStreamWriter has it so I want to make 100% sure it's dealt with automatically.</p>
]]></description><link>https://forum.qt.io/topic/79809/qxmlstreamreader-codec</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 22:37:57 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/79809.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 31 May 2017 14:51:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QXmlStreamReader Codec on Wed, 31 May 2017 18:45:35 GMT]]></title><description><![CDATA[<p dir="auto">Hi! Yes, the codec is automatically set depending on the <code>encoding</code> attribute if <code>QT_NO_TEXTCODEC</code> is not defined. See <a href="http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/xml/qxmlstream.cpp#n1809" target="_blank" rel="noopener noreferrer nofollow ugc">qxmlstream.cpp</a>:</p>
<pre><code>#ifdef QT_NO_TEXTCODEC
                readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread);
#else
                QTextCodec *const newCodec = QTextCodec::codecForName(name.toLatin1());
                if (!newCodec)
                    err = QXmlStream::tr("Encoding %1 is unsupported").arg(name);
                else if (newCodec != codec &amp;&amp; !lockEncoding) {
                    codec = newCodec;
                    delete decoder;
                    decoder = codec-&gt;makeDecoder();
                    decoder-&gt;toUnicode(&amp;readBuffer, rawReadBuffer.data(), nbytesread);
                }
#endif // QT_NO_TEXTCODEC
</code></pre>
]]></description><link>https://forum.qt.io/post/396552</link><guid isPermaLink="true">https://forum.qt.io/post/396552</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 31 May 2017 18:45:35 GMT</pubDate></item></channel></rss>