title: Python urllib.request and utf8 decoding question
body: <p>I'm writing a simple Python CGI script that grabs a webpage and displays the HTML file in the web browser (acting like a proxy).   Here is the script:</p>
  
  <pre><code>#!/usr/bin/env python3.0
  
  import urllib.request
  
  site = "http://reddit.com/"
  site = urllib.request.urlopen(site)
  site = site.read()
  site = site.decode('utf8')
  
  print("Content-type: text/html\n\n")
  print(site)
  </code></pre>
  
  <p>This script works fine when run from the command line, but when it gets to viewing it with a web browser, it shows a blank page.  Here is the error I get in Apache's error_log:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/public/projects/proxy/script.cgi", line 11, in &lt;module&gt;
      print(site)
    File "/usr/local/lib/python3.0/io.py", line 1491, in write
      b = encoder.encode(s)
    File "/usr/local/lib/python3.0/encodings/ascii.py", line 22, in encode
      return codecs.ascii_encode(input, self.errors)[0]
  UnicodeEncodeError: 'ascii' codec can't encode character '\u2019' in position 33777: ordinal not in range(128)
  </code></pre>