6
votes

When I launch my app, I get this error UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 2566: invalid continuation byte. I use UTF8 in my HTML file

<meta charset="utf-8" />

and in my Python file

# -*- coding: utf-8 -*-
self.response.headers['Content-Type'] = 'text/html; charset=UTF-8'

I saw some solutions on the Web using the encode() function but I don't want to insert text in the Python file but in HTML file.

2
Can you post a traceback? Where is that byte coming from? Are you actually saving the file as UTF-8, or just telling Python that you did?Wooble
It appears the editor you're using does not save as UTF-8 by default.Mark Ransom
@MarkRansom I use IDLE and I configure it to save files in UTF-8 by default.tsil
@IsmaelToé, does that include your HTML too?Mark Ransom

2 Answers

9
votes

If you are using Notepad++ make sure the "encoding" (in the menu) of all your files is set to "UTF-8".

I don't know for other editors but that might be the problem.

-4
votes

change to

# -*- coding: latin1 -*-

0xe9 is part of the latin1 charset.