<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><span class=""><div class="gmail_extra"><br><div class="gmail_quote">On 1 December 2017 at 12:18, Florian Bruhin <span dir="ltr"><<a href="mailto:me@the-compiler.org" target="_blank">me@the-compiler.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_4209468316225748356gmail-"><br>
<br>
</span>Yes, thinking about it again, I was wrong there - sorry! If you can't force<br>
robocopy to output UTF-8, the best (and probably correct) guess is<br>
<div>​​</div>locale.getpreferredencoding():<br>
<a href="https://docs.python.org/3/library/locale.html#locale.getpreferredencoding" rel="noreferrer" target="_blank">https://docs.python.org/3/libr<wbr>ary/locale.html#locale.getpref<wbr>erredencoding</a><br>
<br>
The documentation for subprocess mentions that it's using<br>
locale.getpreferredencoding(Fa<wbr>lse) if no encoding was given. I'm still not sure<br>
what that argument (do_setlocale) means exactly, but you might want to just do<br>
the same.<br>
</blockquote></div></div><div class="gmail_extra"><br></div></span><div class="gmail_extra"><div>​Dear Florian,</div><div><br></div><div>This is <i>almost</i> what I was always looking for, which nobody has come up with till now...!!!  But read on....<br></div><div><br></div><div>All the people elsewhere who have been saying use utf-8 or utf-16 or the file system encoding or all the other things have been doing my head in... :(</div><div><br></div><div>After I had penned my long epistle to you earlier, I discovered that, although some of the solutions had <i>appeared</i> to work in that I no longer got the conversion error, ​it turns out they were then <i>displaying</i> that <span style="font-family:monospace,monospace">£</span> character differently, e.g. as the "oe" character or other symbol.</div><div><br></div><div>I discovered for myself that <u><i>only</i></u> <span style="font-family:monospace,monospace">decode("cp850")</span> caused it to display as the desired <span style="font-family:monospace,monospace">£</span>.  And that's because UK/Western Europe is <b>Code Page 850</b>.  So it all fits together now!</div><div><br></div><div>Now, I <i>assumed</i> your suggestion of ​<span style="font-family:monospace,monospace">locale.getpreferredencoding()</span> would return <span style="font-family:monospace,monospace">cp850</span> under Windows (remember, I do not have Windows python to test).  But I checked with my Windows stakeholder, and it does not --- it returns the "windows_1252" type string, which we know does <i>not</i> get the <span style="font-family:monospace,monospace">£</span> right....</div><div><br></div><div>Then, I got him to open a Command Prompt, and just enter the command:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><span style="font-family:monospace,monospace">c:\Tmp> <b>chcp</b><br>Active code page: 850</span><br></div></blockquote><div><br></div><div>That response from <span style="font-family:monospace,monospace">chcp</span> of <span style="font-family:monospace,monospace">850</span> as the CP is precisely what I am looking for....!!!</div><div><br></div><div><i>Soooo</i>, I have a little request-task for you!  Assuming you have Windows + Python 3, can you find a native Qt/PyQt/Python call which returns that under Windows, please, please??  If you're not UK, obviously your CP value may vary, but you know what I'm seeking.  Thank you so much!</div><div><br></div><div>BTW, in <a href="http://doc.qt.io/qt-5/qprocess.html" target="_blank">http://doc.qt.io/qt-5/<wbr>qprocess.html</a> I do not see any mention of "encoding at all"?  Where were you getting your second paragraph above from?<br></div><br></div></div></div></div>