This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: python won't display greek characters in apache under windows
Type: behavior Stage: resolved
Components: Unicode, Windows Versions: Python 3.4
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, nickl1, terry.reedy
Priority: normal Keywords:

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:50adminsetgithub: 63117
2013-09-06 19:27:23terry.reedysetresolution: works for me
stage: resolved
2013-09-06 19:15:11nickl1setstatus: open -> closed
2013-09-06 19:14:07terry.reedysetnosy: + terry.reedy
messages: + msg197095
2013-09-04 12:13:18nickl1setmessages: + msg196904
2013-09-04 04:01:22nickl1setnosy: + ezio.melotti
components: + Unicode, Windows
2013-09-04 03:59:43nickl1create