<?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[The most bizarre bug I have ever seen, Random Chinese translation? How can this happen?]]></title><description><![CDATA[<p dir="auto">I was working with the datalogging of my Qt application when I suddenly did one thing which caused that entire log to change from plain english into Chinese or something. And all that is caused by one single line of code.</p>
<p dir="auto">At first I was having this output:</p>
<pre><code>&lt;&lt; 80
&lt;&lt; 3b
0x80 command case 3b
&lt;&lt; 1
&lt;&lt; 0
WiD = W1.csv
size of transfer = 13 bytes"1";"10111213141516171819"
highNibble = 1 lowNibble = 0
highNibble = 1 lowNibble = 1
highNibble = 1 lowNibble = 2
highNibble = 1 lowNibble = 3
highNibble = 1 lowNibble = 4
highNibble = 1 lowNibble = 5
highNibble = 1 lowNibble = 6
highNibble = 1 lowNibble = 7
highNibble = 1 lowNibble = 8
highNibble = 1 lowNibble = 9
Text read and send!
</code></pre>
<p dir="auto">Though it is well it lacks something, you don't see the byte value the machine transmits. So in my send function I added one line of code.</p>
<pre><code>communication_log &lt;&lt; cAsHex &lt;&lt; "&gt;&gt; \n";  // communication log is a Qdatastream which stuffs bytes in a .txt file
</code></pre>
<p dir="auto">I have near identical line in qDebug(), the debug output did look fine:</p>
<pre><code>"\u0016"  &gt;&gt;
highNibble = 1 lowNibble = 6
"\u0017"  &gt;&gt;
highNibble = 1 lowNibble = 7
"\u0018"  &gt;&gt;
highNibble = 1 lowNibble = 8
"\u0019"  &gt;&gt;
highNibble = 1 lowNibble = 9
Text read and send!
</code></pre>
<p dir="auto">But how did the logfile look like?:</p>
<pre><code>ਣ㰼㠠ਰ㰼㌠੢砰〸挠浯慭摮挠獡⁥戳㰊‼쌱㺿‾Ἂ㸾ਠ㸊‾
㸾ਠ㸐‾ᄊ㸾ਠ㸒‾ጊ㸾ਠ㸔‾ᔊ㸾ਠ㸖‾ᜊ㸾ਠ㸘‾ᤊ㸾ਠ㰊‼ਰ楗⁄‽ㅗ挮癳猊穩⁥景琠慲獮敦⁲‽㌱戠瑹獥ㄢ㬢ㄢ㄰ㄱㄲㄳㄴㄵㄶㄷㄸ∹栊杩乨扩汢⁥‽‱潬乷扩汢⁥‽ਰ楨桧楎扢敬㴠ㄠ氠睯楎扢敬㴠ㄠ栊杩乨扩汢⁥‽‱潬乷扩汢⁥‽ਲ楨桧楎扢敬㴠ㄠ氠睯楎扢敬㴠㌠栊杩乨扩汢⁥‽‱潬乷扩汢⁥‽਴楨桧楎扢敬㴠ㄠ氠睯楎扢敬㴠㔠栊杩乨扩汢⁥‽‱潬乷扩汢⁥‽ਸ਼楨桧楎扢敬㴠ㄠ氠睯楎扢敬㴠㜠栊杩乨扩汢⁥‽‱潬乷扩汢⁥‽ਸ楨桧楎扢敬㴠ㄠ氠睯楎扢敬㴠㤠吊硥⁴敲摡愠摮猠湥Ⅴ迂㸾ਠ迂㸾ਠ迂㸾ਠ迂㸾ਠ迂㸾ਠ迂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ诂㸾ਠ诂㸾ਠ軂㸾ਠ軂㸾ਠ賂㸾ਠ賂㸾ਠ跂㸾ਠ跂㸾ਠ诂㸾ਠ诂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ跂㸾ਠ
</code></pre>
<p dir="auto">Everything was in I believe Chinese. For the fun I also stuffed in Google translate. It could not auto ID the language so I manually selected Chinese. It also did not want to translate into english but it did translate in my native language dutch. I must add that this.... thing.. occured while viewing it in the program 'gedit' of ubuntu. Using the terminal and nano it looked normal.</p>
<p dir="auto">As example this characters 跂 does not translate in english but in Dutch I got "voet met zes tenen" or "Feet with six toes" :D. Gotta luv computers and programming</p>
<p dir="auto">The 'guilty' function is:</p>
<pre><code>void MainWindow::send(QString c)  // c is a single byte casted to a QString
{
    timer-&gt;start(2);         // sets a timer at 2 ms

    serial-&gt;write(c.toLatin1()); // sends a byte overthe serial port
    QString cAsHex = QString("%1").arg(c, 0, 16); // makes a hex value to be shown on the CLI

    qDebug() &lt;&lt; cAsHex &lt;&lt; " &gt;&gt;"; // show the send byte as a Hex value

    QFile log("communication_log.txt");
    log.open(QIODevice::Append);
    QTextStream communication_log(&amp;log);
    communication_log &lt;&lt; cAsHex &lt;&lt; "&gt;&gt; \n"; // I tried all kinds of combination and type casts and such, seems to have no effect
    log.close();

    while (Timer == true) {;}    // waits for timeOut to happen
}
</code></pre>
<p dir="auto">How can that one line of code change the text file so gedit things it the content is some kind of unicode for Chinese??</p>
]]></description><link>https://forum.qt.io/topic/81448/the-most-bizarre-bug-i-have-ever-seen-random-chinese-translation-how-can-this-happen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 02 May 2026 07:03:24 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/81448.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 18 Jul 2017 13:03:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to The most bizarre bug I have ever seen, Random Chinese translation? How can this happen? on Thu, 20 Jul 2017 06:20:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hskoglund">@<bdi>hskoglund</bdi></a> said in <a href="/post/405334">The most bizarre bug I have ever seen, Random Chinese translation? How can this happen?</a>:</p>
<blockquote>
<p dir="auto">Hi, do you delete the ""communication_log.txt" file every time before running your app? Otherwise it could be some junk characters lingering at start of the file that causes your Chinese woes...</p>
</blockquote>
<p dir="auto">Yes I do. The log's purpose is to locate bugs so I have no need to keep track of previous logs.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/artwaw">@<bdi>artwaw</bdi></a> said in <a href="/post/405523">The most bizarre bug I have ever seen, Random Chinese translation? How can this happen?</a>:</p>
<blockquote>
<p dir="auto">Hi,<br />
have you tried:<br />
<code>log.open(QIODevice::Text | QIODevice::Append);</code>?</p>
</blockquote>
<p dir="auto">No I have not. I think I will add it. I already changed some code and it does not happen anymore, but I'll add it anyway ;)</p>
]]></description><link>https://forum.qt.io/post/405661</link><guid isPermaLink="true">https://forum.qt.io/post/405661</guid><dc:creator><![CDATA[bask185]]></dc:creator><pubDate>Thu, 20 Jul 2017 06:20:56 GMT</pubDate></item><item><title><![CDATA[Reply to The most bizarre bug I have ever seen, Random Chinese translation? How can this happen? on Wed, 19 Jul 2017 11:16:03 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
have you tried:<br />
<code>log.open(QIODevice::Text | QIODevice::Append);</code>?</p>
]]></description><link>https://forum.qt.io/post/405523</link><guid isPermaLink="true">https://forum.qt.io/post/405523</guid><dc:creator><![CDATA[artwaw]]></dc:creator><pubDate>Wed, 19 Jul 2017 11:16:03 GMT</pubDate></item><item><title><![CDATA[Reply to The most bizarre bug I have ever seen, Random Chinese translation? How can this happen? on Wed, 19 Jul 2017 11:09:43 GMT]]></title><description><![CDATA[<p dir="auto">Maybe using a hex editor viewing the first bytes of the file can help?<br />
This seems to be a misinterpreted encoding.</p>
]]></description><link>https://forum.qt.io/post/405521</link><guid isPermaLink="true">https://forum.qt.io/post/405521</guid><dc:creator><![CDATA[sneubert]]></dc:creator><pubDate>Wed, 19 Jul 2017 11:09:43 GMT</pubDate></item><item><title><![CDATA[Reply to The most bizarre bug I have ever seen, Random Chinese translation? How can this happen? on Tue, 18 Jul 2017 13:17:11 GMT]]></title><description><![CDATA[<p dir="auto">Hi, do you delete the ""communication_log.txt" file every time before running your app? Otherwise it could be some junk characters lingering at start of the file that causes your Chinese woes...</p>
]]></description><link>https://forum.qt.io/post/405334</link><guid isPermaLink="true">https://forum.qt.io/post/405334</guid><dc:creator><![CDATA[hskoglund]]></dc:creator><pubDate>Tue, 18 Jul 2017 13:17:11 GMT</pubDate></item></channel></rss>