How to make Popen() understand UTF-8 properly?
<p>This is my code in Python:</p>

<pre><code>[...]
proc = Popen(path, stdin=stdin, stdout=PIPE, stderr=PIPE)
result = [x for x in proc.stdout.readlines()]
result = ''.join(result);
</code></pre>

<p>Everything works fine, when it's ASCII. When I'm receiving UTF-8 text in <code>stdout</code> the result is unpredictable. In most cases the output is damaged. What is wrong here?</p>

<p>Btw, maybe this code should be optimized somehow?</p>
