If I execute the following Python 3.1 program, I see only � instead of the correct characters in my browser. The file itself is UTF-8 encoded and the same encoding is sent with the response.
from wsgiref.simple_server import make_server
page = "<html><body>äöü€ßÄÖÜ</body></html>"
def application(environ, start_response):
start_response("200 Ok", [("Content-Type", "text/html; charset=UTF-8")])
return page
httpd = make_server('', 8000, application)
print("Serving on port 8000...")
httpd.serve_forever()
"UTF-8" is set correctly in the response:
HTTP/1.0 200 Ok
Date: Mon, 09 Aug 2010 16:35:02 GMT
Server: WSGIServer/0.1 Python/3.1.1+
Content-Type: text/html; charset=UTF-8
What is wrong here?