7

This is a django project.

I have a simple view with 1 line in it : render_to_response('index.html'). And this index.html contains characters like "öüä" which trigger the error 'utf8' codec can't decode bytes in position 1942-1944: invalid data .

This is straightforward error which kind of says that it can't decode because this is not utf8 , yet i can't understand how to fix it . Where exactly should i specify something .

Any suggestions ?

1 Answer 1

5

index.html is most likely in a non-UTF-8 encoding, possibly ISO-8859-1 or Windows-1252. A hex editor is a good thing to use in these cases to examine how the ö et.c. are stored.

If index.html where in UTF-8, an ö would correspond to two bytes, c3 b6. If it is ISO-8859-1, it will be a single byte f6.

To solve this, either recode the file in UTF-8 or choose the right codec.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. You were right , my IDE had other encoding by default. Don't know why i didn't think of it =). After i changed it in IDE everything worked fine.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.