title: Unicode error when outputting python script output to file
body: <p>This is the code:</p>
  
  <pre><code>print '"' + title.decode('utf-8', errors='ignore') + '",' \
        ' "' + title.decode('utf-8', errors='ignore') + '", ' \
        '"' + desc.decode('utf-8', errors='ignore') + '")'
  </code></pre>
  
  <p>title and desc are returned by Beautiful Soup 3 (<em>p[0].text</em> and <em>p[0].prettify</em>) and as far as I can figure out from BeautifulSoup3 documentation are UTF-8 encoded.</p>
  
  <p>If I run</p>
  
  <pre><code>python.exe script.py &gt; out.txt
  </code></pre>
  
  <p>I get following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "script.py", line 70, in &lt;module&gt;
      '"' + desc.decode('utf-8', errors='ignore') + '")'
  UnicodeEncodeError: 'ascii' codec can't encode character u'\xf8' in position 264
  : ordinal not in range(128)
  </code></pre>
  
  <p>However if I run </p>
  
  <pre><code>python.exe script.py
  </code></pre>
  
  <p>I get no error. It happens only if output file is specified.</p>
  
  <p>How to get good UTF-8 data in the output file?</p>