UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9

Morning, everyone,
I’m trying to use Django to move forward on a project, so I started with the tutorial of the Django site. Arrived at the creation of my first template (index.html), in the third part, I stumbled on the following error:
“‘utf-8’ codec can’t decode byte 0xe9 in position 599: invalid continuation byte”
Can someone help me?
Thank you

Do you have the character é in your template? (That’s what 0xe9 is in the extended US ASCII character set. I guess it could be different in other national character sets.)

If you’ve done a copy-paste of your template from a different source, it’s possible that you picked up an invalid character when doing your copy.

But without seeing the template you’re trying to use, or the context that is attempting to be rendered, we’re not going to be able to address the specifics of this issue.

You could try changing your DEFAULT_CHARSET to your languages native charset. (I’m fairly sure there’s also a parameter you could pass somewhere during the rendering process to set that as well.)

DEFAULT_CHARSET doesn’t affect the opening of the template file, so I’m not sure it will help.

Thank you for your response. Indeed, an “é” character contained in the author’s name (in the template properties) that was problematic. I removed this information in the properties… and it’s now an “ê” in a " En-t�te Ca" that seems to block… but I can’t find where this information is located :frowning:
Since I am only a beginner in these programming languages, I only reproduce by “copy/paste” the examples proposed in the tutorial :
Thank you for your help

I’m sorry, but I’m not understanding what you mean by “ê” in a " En-t�te Ca " that seems to block…". At what part of the process is this happening? What file are you editing? Or is this happening when you’re actually running the example? (I’m going to need you to provide more information and detail before I’m going to be able to provide you with any assistance.)

On a side-note, and not directly relating to the root issue trying to be addressed here, I’m going to digress for a moment.

I understand that as a beginner that you can only follow the example along exactly. I agree that that’s the best way to do it at first.

But for a couple of reasons, it’s generally recommended that you type the text yourself rather than just copy/paste the text into the file. It actually provides at least two benefits - first, it has been demonstrated that you will learn and understand more by doing the typing yourself. You will be forcing your eyes to read every character that is in the example, and that helps reinforce the syntax of the language. Second, it is almost certain that you will make at least one typo while doing so, and the exercise of finding what’s different between what you’ve typed and what the example has is instructive in its own right.

Thank you for your response. For info I am French and my computer is configured in French (as well as almost all the software installed on it).
When I said that I was only doing a “copy/paste”, it’s a bit limiting. Indeed, I’m trying to understand the logic of Django and Python in order to transpose my experiences in the development of a POC for a much more complex project I’m working on.
I fully agree and conscient that writing is preferable to “copy/paste”. Being usually careful in what I do, I took this freedom to try to save time. I do, however, check all my handwriting for possible mistakes. What I have a hard time finding is the information that Django (or python) will look for, apart from what I could write (or paste) in the different files.In this case, I don’t see at all where Python will look for this “en-tête CA”. In the previous problem, I was able to make the link with the properties of the html file I created… but is it due to the fact that I use Word to create my html files?

Yes, using Word would be extremely problematic - and not just in this specific case. Word also has a tendency to replace things like standard quotes with the “fancier” open and close quote characters. (There are other substitutions that occur as well.)

What you really want to look for is a “text editor” as opposed to a “word processor”.

Recently, I’ve been recommending people use Visual Studio Code for doing their development work. But if you want something “smaller”, Notepad++ is a really good text editor. But, in a pinch, regular old Windows notepad should do you just fine.

But you still haven’t provided the details as to how and where you’re getting this error message. (Is this showing up in the terminal session where you’re running runserver? Is it appearing in your browser when you’re trying to view a page? - if so, which page, what URL?) The more specific information you provide, the better chance I have of identifying what’s happening. Otherwise, I can’t help you locate the root issue.

Thank you for your response. So I have attached 2 print-screen.
Does that give you more info?
If not, tell me what I can provide you to make it clearer.

Ok, so it’s telling you that the character causing problems is at location 36745 in the file.

You’ll have to look at your template at that position to figure out what’s causing the issue. How you find position 36745 in your template depends upon your tools. (For example, Notepad++ lets you go to a specific character offset using Ctrl-G.)

Thank you for your answer. However, I don’t know which document is referred to… because the longest (setting) is only 130 lines. As for the html documents, the index is only about 15 lines long :frowning:

Well, finally rewriting the html files with notepad solved my decoding problem :slight_smile:
Thanks for your lighting

There is a better way:
Google the following:“how to set utf 8 in eclipse”
answer that works for me:
Open Eclipse and do the following steps: Window → Preferences → Expand General and click Workspace, text file encoding (near bottom) has an encoding chooser. Select “Other” radio button → Select UTF - 8 from the drop down. Click Apply and OK button OR click simply OK button.

I know its a year later but it might help the next victim.