Issue 18917: python won't display greek characters in apache under windows (original) (raw)

Issue18917

Created on 2013-09-04 03:59 by nickl1, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg196886 - (view) Author: Nick (nickl1) Date: 2013-09-04 03:59
I've set up apache on Windows 7 and I'm running python with cgi. I have a script that contains this: #!C:\Python34\python.exe print ("Content-Type: text/html; charset=utf-8\n") print ("Δοκιμή") Pretty simple, right? When I'm opening the page to my browser in stead of "Δοκιμή" I get weird ��� symbols (when the browser is set on UTF-8) If I set my browser to ISO-8859-7 I will get the normal greek letters. "sys.stdout.encoding" will display "cp1253" instead of "utf-8" as it probably should. scripts with only english characters will work totally fine. the problems seems to be on non-english characters. it displays them as ISO-8859-7. this doesn't seem to be an apache or windows issue as PHP and Lua will run just fine and all the scripts will display greek characters in my browser. the problem occurs only with python.
msg196904 - (view) Author: Nick (nickl1) Date: 2013-09-04 12:13
Turns out adding "SetEnv PYTHONIOENCODING utf-8" to the end of apache's httpd.conf file fixed the problem for me.
msg197095 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-09-06 19:14
I believe that this is *the* answer to the issue, so the issue should be closed.
History
Date User Action Args
2022-04-11 14:57:50 admin set github: 63117
2013-09-06 19:27:23 terry.reedy set resolution: works for mestage: resolved
2013-09-06 19:15:11 nickl1 set status: open -> closed
2013-09-06 19:14:07 terry.reedy set nosy: + terry.reedymessages: +
2013-09-04 12:13:18 nickl1 set messages: +
2013-09-04 04:01:22 nickl1 set nosy: + ezio.melotticomponents: + Unicode, Windows
2013-09-04 03:59:43 nickl1 create