Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fdn.fr!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'error:': 0.07; 'nicely': 0.07; 'python3': 0.07; 'subject:script': 0.09; 'apache': 0.15; '"r")': 0.16; 'codec': 0.16; 'ordinal': 0.16; 'subject:Unicode': 0.16; 'sat,': 0.16; 'solution.': 0.20; 'header:User-Agent:1': 0.23; 'byte': 0.24; "i've": 0.25; 'script': 0.25; 'gives': 0.31; "skip:' 10": 0.31; 'prints': 0.31; 'anyone': 0.31; 'me?': 0.32; 'run': 0.32; 'skip:# 10': 0.33; 'subject:with': 0.35; "can't": 0.35; 'done': 0.36; 'hi,': 0.36; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'skip:u 10': 0.60; 'skip:o 30': 0.61; 'charset:windows-1252': 0.65; 'webpage': 0.68; 'jul': 0.74; '1997': 0.84 Date: Fri, 15 Aug 2014 20:10:25 +0200 From: Dominique Ramaekers User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: python-list@python.org Subject: Unicode in cgi-script with apache2 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Fri, 15 Aug 2014 21:17:29 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408130249 news.xs4all.nl 2903 [2001:888:2000:d::a6]:47198 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76382 Hi, I've got a little script: #!/usr/bin/env python3 print("Content-Type: text/html") print("Cache-Control: no-cache, must-revalidate") # HTTP/1.1 print("Expires: Sat, 26 Jul 1997 05:00:00 GMT") # Date in the past print("") f = open("/var/www/cgi-data/index.html", "r") for line in f: print(line,end='') If I run the script in the terminal, it nicely prints the webpage 'index.html'. If access the script through a webbrowser, apache gives an error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1791: ordinal not in range(128) I've done a hole afternoon of reading on fora and blogs, I don't have a solution. Can anyone help me? Greetings, Dominique.