If you create this app.py
#!/usr/bin/python3
print("Content-Type: text/plain;charset=utf-8\n")
print("Hello World!")
and you enable CGI in .htaccess with:
Options +ExecCGI
AddHandler cgi-script .py
it totally works: http://example.com/app.py displays "Hello world!".
However if you add an accented character:
print("Quel été!")
this does not work anymore: the output page is empty in the browser.
Question: how to output a UTF8 content with Python3 + mod_cgi?
NB:
- the .py file is saved with UTF8 encoding. 
- Might be related: https://redmine.lighttpd.net/issues/2471 
- Fun fact: running - #!/usr/bin/python3 import sys print("Content-Type: text/plain;charset=utf-8\n") print(str(sys.stdout.encoding))- from command-line gives - UTF-8but running it trough- mod_cgioutputs- ANSI_X3.4-1968in http://example.com/app.py.- Setting - export PYTHONIOENCODING=utf8did not change anything, probably because it's Apache + mod_cgi that calls this Python code.
 
    