Dominique Ramaekers wrote:

> As I suspected, if I check the used encoding in wsgi I get:
> ANSI_X3.4-1968
> 
> I found you can define the coding of the script with a special comment:
> # -*- coding: utf-8 -*-
> 
> Now I don't get an error but my special chars still doesn't display well.
> The script:
> # -*- coding: utf-8 -*-
> import sys
> def application(environ, start_response):
>      status = '200 OK'
>      output = 'Hello World! é ü à ũ'
>      #output = sys.getfilesystemencoding() #1
> 
>      response_headers = [('Content-type', 'text/plain'),
>                          ('Content-Length', str(len(output)))]
>      start_response(status, response_headers)
> 
>      return [output]
> 
> Gives in the browser as output:
> 
> Hello World! é ü à ũ

That's UTF-8 interpreted as Latin-1. Try specifying the charset in the 
header:

...
response_headers = [('Content-type', 'text/plain; charset=utf-8'),
...
 
> And if I check the encoding with the python script (uncommenting line
> #1), I still get ANSI_X3.4-1968


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to