<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi Dylan,<br>
<br>
The backslashes you see in the output are only added when you print the string, not actual characters of the string:<br>
<br>
"\"Intex Aqua Fish\""<br>
<br>
So what you need is to replace just the doublequotes - try data.replace("\"", "") or better data.remove('"').<br>
<br>
BR,<br>
Martin<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF839780" style="direction: ltr;"><font size="2" color="#000000" face="Tahoma"><b>From:</b> Devel [devel-bounces@lists.sailfishos.org] on behalf of Dylan Van Assche via Devel [devel@lists.sailfishos.org]<br>
<b>Sent:</b> Tuesday, September 12, 2017 2:23 PM<br>
<b>To:</b> Sailfish OS Developers mailing list<br>
<b>Subject:</b> Re: [SailfishDevel] QT String issue<br>
</font><br>
</div>
<div></div>
<div>
<div>Hi Dmitriy,<br>
</div>
<div><br>
</div>
<div>For some reason, it doesn't work...<br>
</div>
<div><br>
</div>
<div><span class="colour" style="color:rgb(192,192,192)"></span><span class="colour" style="color:rgb(128,0,128)">QString</span><span class="colour" style="color:rgb(192,192,192)">
</span><span class="colour" style="color:rgb(0,0,0)">data</span><span class="colour" style="color:rgb(192,192,192)">
</span><span class="colour" style="color:rgb(0,0,0)">=</span><span class="colour" style="color:rgb(192,192,192)">
</span><span class="colour" style="color:rgb(0,0,0)">line.split(</span><span class="colour" style="color:rgb(0,128,0)">'='</span><span class="colour" style="color:rgb(0,0,0)">,</span><span class="colour" style="color:rgb(192,192,192)">
</span><span class="colour" style="color:rgb(128,0,128)">QString</span><span class="colour" style="color:rgb(0,0,0)">::</span><span class="colour" style="color:rgb(128,0,128)">SkipEmptyParts</span><span class="colour" style="color:rgb(0,0,0)">).at(</span><span class="colour" style="color:rgb(0,0,128)">1</span><span class="colour" style="color:rgb(0,0,0)">);</span><br>
</div>
<pre style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px"><span class="colour" style="color:rgb(0,0,0)">data</span><span class="colour" style="color:rgb(0,0,0)">.</span><span class="colour" style="color:rgb(0,0,0)">replace</span><span class="colour" style="color:rgb(0,0,0)">(</span><span class="colour" style="color:rgb(0,128,0)">"\\\""</span><span class="colour" style="color:rgb(0,0,0)">,</span><span class="colour" style="color:rgb(192,192,192)"> </span><span class="colour" style="color:rgb(0,128,0)">""</span><span class="colour" style="color:rgb(0,0,0)">);</span><br></pre>
<pre style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px"><span class="colour" style="color:rgb(0,0,0)">dataList</span><span class="colour" style="color:rgb(0,0,0)">.</span><span class="colour" style="color:rgb(0,0,0)">append</span><span class="colour" style="color:rgb(0,0,0)">(</span><span class="colour" style="color:rgb(0,0,0)">qMakePair</span><span class="colour" style="color:rgb(0,0,0)">(</span><span class="colour" style="color:rgb(0,0,0)">querry</span><span class="colour" style="color:rgb(0,0,0)">,</span><span class="colour" style="color:rgb(192,192,192)"> </span><span class="colour" style="color:rgb(0,0,0)">data</span><span class="colour" style="color:rgb(0,0,0)">));</span><br></pre>
<div><br>
</div>
<div><span class="colour" style="color:rgb(0,0,0)">This is my code now, but the result is still the same for some reason.</span><br>
</div>
<div><span class="colour" style="color:rgb(0,0,0)">I think I do something still wrong :(</span><br>
</div>
<div><br>
</div>
<div>Cheers,<br>
</div>
<div>Dylan</div>
<div><br>
</div>
<blockquote class="protonmail_quote" type="cite">
<div>
<div>-------- Original Message --------<br>
</div>
</div>
<div>Subject: Re: [SailfishDevel] QT String issue<br>
</div>
<div>Local Time: 12 September 2017 2:13 PM<br>
</div>
<div>UTC Time: 12 September 2017 12:13<br>
</div>
<div>From: dylan.van.assche@protonmail.com<br>
</div>
<div>To: Sailfish OS Developers mailing list <devel@lists.sailfishos.org><br>
</div>
<div><br>
</div>
<div>Hi Dmitriy,<br>
</div>
<div><br>
</div>
<div>Thanks for the information! I just started to learn QT C++ :)<br>
</div>
<div><br>
</div>
<div>Cheers,<br>
</div>
<div>Dylan<br>
</div>
<div class="protonmail_signature_block protonmail_signature_block-empty">
<div class="protonmail_signature_block-user protonmail_signature_block-empty">
<div><br>
</div>
</div>
<div class="protonmail_signature_block-proton protonmail_signature_block-empty"><br>
</div>
</div>
<div><br>
</div>
<blockquote class="protonmail_quote" type="cite">
<div>-------- Original Message --------<br>
</div>
<div>Subject: Re: [SailfishDevel] QT String issue<br>
</div>
<div>Local Time: 12 September 2017 12:41 PM<br>
</div>
<div>UTC Time: 12 September 2017 10:41<br>
</div>
<div>From: dpurgin@gmail.com<br>
</div>
<div>To: Dylan Van Assche <dylan.van.assche@protonmail.com>, Sailfish OS Developers <devel@lists.sailfishos.org><br>
</div>
<div><br>
</div>
<div dir="ltr">
<div>
<div>
<div>
<div>Hi Dylan,<br>
</div>
</div>
<div>trimmed() removes whitespaces only. You need to replace \" with an empty string and "escape" both \ and ". You need escaping because this is how string literals in C/C++ work. Try calling str.replace("\\\"", ""), where str an object of QString.<br>
</div>
</div>
<div><br>
</div>
<div>Also note that trimmed() is a const method and does not change the object for which it was called. I.e.
<br>
</div>
<div><br>
</div>
<div>QString str1 = "  a  ";<br>
</div>
<div>str1.trimmed();<br>
</div>
<div>// str1 is unchanged but returns a QString object which is "a"<br>
</div>
<div><br>
</div>
<div>Cheers<br>
</div>
</div>
<div>Dmitriy<br>
</div>
<div>
<div><br>
</div>
</div>
</div>
<div class="gmail_extra">
<div><br>
</div>
<div class="gmail_quote">
<div>On Tue, Sep 12, 2017 at 12:25 PM, Dylan Van Assche via Devel <span dir="ltr">
<<a href="redir.aspx?REF=hSOZmXePy6vw3rU4NUCBUwLqgjh9Mo0neXylsazEc6WCX10P2vnUCAFtYWlsdG86ZGV2ZWxAbGlzdHMuc2FpbGZpc2hvcy5vcmc." target="_blank">devel@lists.sailfishos.org</a>></span> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>Hi,<br>
</div>
<div><br>
</div>
<div>I'm reading the sfos-release and the hw-release file in /etc from C++ but for some lines I get this in my strings as output: <br>
</div>
<div><br>
</div>
<div class="m_6315283050251290310protonmail_signature_block m_6315283050251290310protonmail_signature_block-empty">
<div class="m_6315283050251290310protonmail_signature_block-user m_6315283050251290310protonmail_signature_block-empty">
<div><br>
</div>
</div>
<div class="m_6315283050251290310protonmail_signature_block-proton m_6315283050251290310protonmail_signature_block-empty">
<br>
</div>
</div>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span class="colour" style="color:rgb(170,0,0)">"\"Intex Aqua Fish\""</span><br>
</p>
<div><br>
</div>
<div>I tried trimmed() and remove() but I can't figure out how to clean it correctly. The \" characters are annoying.<br>
</div>
<div><br>
</div>
<div>Kind regards,<br>
</div>
<div>Dylan Van Assche<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>______________________________<wbr>_________________<br>
</div>
<div>SailfishOS.org Devel mailing list<br>
</div>
<div>To unsubscribe, please send a mail to <a href="redir.aspx?REF=8vYPlC46P7_sdO41Gm9TecKuKsnmL9m4tfz011wxDyj8wF8P2vnUCAFtYWlsdG86ZGV2ZWwtdW5zdWJzY3JpYmVAbGlzdHMuc2FpbGZpc2hvcy5vcmc." target="_blank">
devel-unsubscribe@lists.<wbr>sailfishos.org</a><br>
</div>
</blockquote>
</div>
</div>
</blockquote>
<div><br>
</div>
</blockquote>
<div><br>
</div>
</div>
</div>
</div>
</body>
</html>