<?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[[SOLVED] - QString and encoding (UTF-8)]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm creating an object that has multiple QString, I would like them to support UTF-8 character (for example Chinese, russian, etc.)</p>
<p dir="auto">I have a web service that returns some database field as utf-8 (xml file with utf-8 format)<br />
Here is a real example:<br />
<a href="http://maximumtrainer.com/phprestsql/?username=max3&amp;password=123&amp;lang=fr&amp;getUser=1" target="_blank" rel="noopener noreferrer nofollow ugc">http://maximumtrainer.com/phprestsql/?username=max3&amp;password=123&amp;lang=fr&amp;getUser=1</a><br />
Check for &lt;first_name&gt; and &lt;last_name&gt; for example of UTF-8 varchar</p>
<p dir="auto">When I am parsing this xml in QT, the chinese and russian character show as ???? instead of the real value, I have tested with french character (éèâ, etc.) and those works.  Any idea why the other one are not shown, is it the qDebug console that is not utf-8 ? is it QString that is not utf-8 ?</p>
<p dir="auto">The parsing is not the the problem, because if I set directly the QString value to chinese character, I cannot display it in the console, example :<br />
@user-&gt;first_name = "喜喜";<br />
qDebug() &lt;&lt; "USER FIRST NAME? IS "  &lt;&lt;  user-&gt;first_name;@</p>
<p dir="auto">Thanks if you can give me a hand</p>
]]></description><link>https://forum.qt.io/topic/37837/solved-qstring-and-encoding-utf-8</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 17:00:44 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/37837.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Feb 2014 19:17:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] - QString and encoding (UTF-8) on Mon, 17 Feb 2014 02:32:53 GMT]]></title><description><![CDATA[<p dir="auto">I guess the problem is the console/Windows, like you said JKSH<br />
If I ouput the result in a QLabel, it is displayed correctly<br />
@    QString str = "喜喜";<br />
ui-&gt;label_user-&gt;setText(str);@</p>
<p dir="auto">I'll go code on Ubuntu now :)</p>
<p dir="auto">Thanks for your input guys,</p>
]]></description><link>https://forum.qt.io/post/215135</link><guid isPermaLink="true">https://forum.qt.io/post/215135</guid><dc:creator><![CDATA[maximus]]></dc:creator><pubDate>Mon, 17 Feb 2014 02:32:53 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] - QString and encoding (UTF-8) on Sat, 15 Feb 2014 14:54:21 GMT]]></title><description><![CDATA[<p dir="auto">Hi, you need to make sure that your compiler support utf8 executable charset if you want to use raw Chinese string literals. Though this is not a problem for most compilers, but MSVC have very bad support for utf8 exec-charset.</p>
]]></description><link>https://forum.qt.io/post/214986</link><guid isPermaLink="true">https://forum.qt.io/post/214986</guid><dc:creator><![CDATA[dbzhang800]]></dc:creator><pubDate>Sat, 15 Feb 2014 14:54:21 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] - QString and encoding (UTF-8) on Sat, 15 Feb 2014 03:26:50 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">[quote]<br />
@user-&gt;first_name = "喜喜";@<br />
[/quote]You usually cannot put unicode strings in your source code directly -- your compiler might not understand it.</p>
<p dir="auto">You need to use "Unicode string literals":<a href="http://stackoverflow.com/questions/7636797/unicode-string-literals" target="_blank" rel="noopener noreferrer nofollow ugc">http://stackoverflow.com/questions/7636797/unicode-string-literals</a>, which was introduced in C++11.</p>
<p dir="auto">[quote]<br />
<a class="plugin-mentions-user plugin-mentions-a" href="/user/qdebug">@<bdi>qDebug</bdi></a>() &lt;&lt; "USER FIRST NAME? IS "  &lt;&lt;  user-&gt;first_name;@<br />
[/quote]I'm not 100% sure, but I think qDebug() uses your system's console. Windows' console cannot print Unicode.</p>
<p dir="auto">You can try writing to a QLabel or a QFile instead.</p>
]]></description><link>https://forum.qt.io/post/214961</link><guid isPermaLink="true">https://forum.qt.io/post/214961</guid><dc:creator><![CDATA[JKSH]]></dc:creator><pubDate>Sat, 15 Feb 2014 03:26:50 GMT</pubDate></item></channel></rss>