title: Python / Mako : How to get unicode strings/characters parsed correctly?
body: <p>I'm trying to get Mako render some string with unicode characters :</p>
  
  <pre><code>tempLook=TemplateLookup(..., default_filters=[], input_encoding='utf8',output_encoding='utf-8', encoding_errors='replace')
  ...
  print sys.stdout.encoding
  uname=cherrypy.session['userName']
  print uname
  kwargs['_toshow']=uname
  ...
  return tempLook.get_template(page).render(**kwargs)
  </code></pre>
  
  <p>The related template file :</p>
  
  <pre><code>...${_toshow}...
  </code></pre>
  
  <p>And the output is :</p>
  
  <pre><code>UTF-8
  Deşghfkskhü
  ...
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 1: ordinal not in range(128)
  </code></pre>
  
  <p>I don't think there's any problem with the string itself since I can print it just fine.</p>
  
  <p>Altough I've played (a lot) with <code>input/output_encoding</code> and <code>default_filters</code> parameters, it always complains about being unable to decode/encode with ascii codec.</p>
  
  <p>So I decided to try out the example found on the <a href="http://www.makotemplates.org/docs/unicode.html#unicode" rel="nofollow noreferrer">documentation</a>, and the following works the "best" :</p>
  
  <pre><code>input_encoding='utf-8', output_encoding='utf-8'
  #(note : it still raised an error without output_encoding, despite tutorial not implying it) 
  </code></pre>
  
  <p>With</p>
  
  <pre><code>${u"voix m’a réveillé."} 
  </code></pre>
  
  <p>And the result being </p>
  
  <pre><code>voix mâ�a rÃ©veillÃ©
  </code></pre>
  
  <p>I simply don't get why this doesn't work. "Magic encoding comment"s don't work either. All the files are encoded with UTF-8.</p>
  
  <p>I've spent hours to no avail, am I missing something ?</p>
  
  <p><strike>
  <strong>Update :</strong></p>
  
  <p>I have a simpler question now : </p>
  
  <p>Now that all the variables are unicode, how can I get Mako to render unicode strings without applying anything ? Passing a blank filter / render_unicode() doesn't help.  </strike></p>