szaman
szaman

Reputation: 6756

UnicodeDecodeError in extended template

I have base.html file:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>{% block head.title %}{% endblock %}</title>
    </head>

    <body>
        {% block body.content %}{% endblock %}
    </body>

</html>

and 500.html file:

{% extends "base.html" %}
{% block head.title %}
    500 ł
{% endblock %}

{% block body.content %}
    500 - 
{% endblock %}

When I generate some error I don`t see 500 ł but

UnicodeDecodeError: 'utf8' codec can't decode byte 0xb3 in position 54: unexpected code byte

When I change ł to l everything is fine. I creates new html files with eclipse. What is wrong?

EDIT:

I cannot use any of polish diactric characters

Upvotes: 2

Views: 1795

Answers (2)

Andrew Wilkinson
Andrew Wilkinson

Reputation: 10836

It looks like your template file might not being saved in utf8 by Eclipse. According to this bug it chooses your OS's default encoding, which may not be utf8.

You can configure Eclipse like this:

  • Set the global text file encoding preference Workbench > Editors to "UTF-8".
  • If an encoding other than UTF-8 is required, set the encoding on the individual file rather than using the global preference setting. To do this use the File > Properties > Info menu selection to set the encoding on an individual file.

Or you can use the HTML entity which is &#321; and then it doesn't matter what encoding the file is saved as.

Upvotes: 4

Iain Shelvington
Iain Shelvington

Reputation: 32244

ł is not a valid utf8 character, you will have to replace it with it's ascii character reference &#321;

This website has a useful list of ascii codes for any special characters you want to include in your web pages.

Upvotes: 0

Related Questions