<?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[Use of Unicode in Dynamic Translations related code.]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I have used Unicode "\xE2\x84\x83" in my code.</p>
<p dir="auto">example: TextWidget *test = new TextWidget("\xE2\x84\x83", this);  ----&gt; it makes QString m_text = "\xE2\x84\x83" ;<br />
where m_text is a member variable of TextWidget.</p>
<p dir="auto">this TextWidget reacts to a languageChangeEvent.<br />
In Language change event it returns QObject::tr(m_text);</p>
<p dir="auto">In this case, it returns all question mark symbol.  "????"</p>
<p dir="auto">in my translation file (.ts) I don't have any translation for this Unicode. also Ideally if tr doesn't find any translation then it returns QString::fromUtf8(string) but in my case, it returns all "?????"</p>
<p dir="auto">can anybody help for how to use Unicode in a dynamic translation environment?</p>
<p dir="auto">Thanks in advance.</p>
]]></description><link>https://forum.qt.io/topic/95724/use-of-unicode-in-dynamic-translations-related-code</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 07:07:19 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/95724.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 19 Oct 2018 13:37:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Use of Unicode in Dynamic Translations related code. on Thu, 25 Oct 2018 17:11:46 GMT]]></title><description><![CDATA[<p dir="auto">Please read <a href="http://doc.qt.io/qt-5/i18n-source-translation.html#using-tr-for-all-literal-text" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/i18n-source-translation.html#using-tr-for-all-literal-text</a></p>
<p dir="auto"><code>tr</code> can't translate variables, it must be used only with <a href="https://www.tutorialspoint.com/cplusplus/cpp_constants_literals.htm" target="_blank" rel="noopener noreferrer nofollow ugc">literals</a></p>
<p dir="auto">P.S.<br />
<code>m_text = QObject::tr(text);</code> still doesn't compile, you are using <code>m_text = QObject::tr(text.constData());</code> but it still can't work</p>
]]></description><link>https://forum.qt.io/post/489027</link><guid isPermaLink="true">https://forum.qt.io/post/489027</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Thu, 25 Oct 2018 17:11:46 GMT</pubDate></item><item><title><![CDATA[Reply to Use of Unicode in Dynamic Translations related code. on Thu, 25 Oct 2018 16:35:55 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Yes, it compiles.  I do this</p>
<p dir="auto">QByteArray text = m_immutableText.toLocal8Bit();<br />
m_text = QObject::tr(text);</p>
<p dir="auto">Also, I found this solution for this symbol issue :</p>
<p dir="auto">QTextCodec *utfCodec = QTextCodec::codecForName("UTF-8"); //creating new utf-8 codec<br />
QTextCodec::setCodecForLocale(utfCodec);  // setting the utf-8 codec for the tr() tags</p>
]]></description><link>https://forum.qt.io/post/489021</link><guid isPermaLink="true">https://forum.qt.io/post/489021</guid><dc:creator><![CDATA[PoonamGupta]]></dc:creator><pubDate>Thu, 25 Oct 2018 16:35:55 GMT</pubDate></item><item><title><![CDATA[Reply to Use of Unicode in Dynamic Translations related code. on Fri, 19 Oct 2018 14:14:45 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto"><code>QObject::tr(m_text);</code></p>
</blockquote>
<p dir="auto">Does this even compile?<br />
The problem is not the non-asci chars, <code>tr</code> arguments must be the string literals to translate, not a variable.<br />
<a href="http://doc.qt.io/qt-5/i18n-source-translation.html#using-qt-tr-noop-and-qt-translate-noop-in-c" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/i18n-source-translation.html#using-qt-tr-noop-and-qt-translate-noop-in-c</a></p>
]]></description><link>https://forum.qt.io/post/487896</link><guid isPermaLink="true">https://forum.qt.io/post/487896</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Fri, 19 Oct 2018 14:14:45 GMT</pubDate></item></channel></rss>