[issue22746] cgitb html: wrong encoding for utf-8

R. David Murray report at bugs.python.org
Mon Oct 27 20:54:32 CET 2014


R. David Murray added the comment:

If you look at the file, you'll find that the data is in utf-8 (at least if your locale is a utf-8 locale).  However, html is by default interpreted as latin-1, so that's what the webrowser displays when you pass the file on disk to it.  If you add "encoding='latin-1'" to your open call, your script will work.  What you do if you need to display non-latin1 characters, I don't know.  (See https://bugzil.la/760050, for example).

Note: the above is for python3.  I don't remember how you do the equivalent in python2...a naive codecs.open call just got me a UnicodeDecodeError.

----------
nosy: +r.david.murray
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22746>
_______________________________________


More information about the Python-bugs-list mailing list