title: Why python-cgi fails on unicode?
body: <p>If run this code in console - it works well (it is in Russian), but if run it like cgi on Apache2 server - it fails: <code>&lt;type 'exceptions.UnicodeEncodeError'&gt;: 'ascii' codec can't encode characters in position 8-9: ordinal not in range(128)</code>. The code is:</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: UTF-8 -*-
  
  import cgitb
  cgitb.enable()
  
  print "Content-Type: text/html;charset=utf-8"
  print 
  s=u'Nikolja \u043d\u0435 \u0421\u0430\u0440\u043a\u043e\u0437\u0438!'
  print s#.encode('utf-8')
  </code></pre>
  
  <p>Yes, solution is to uncomment <code>.encode('utf-8')</code>, but i spend more time to understand why than happens and i cant see the answer.</p>