Encoding characters HTML in python

  html, python

I have a problem with one of my python program :

"é" doesn’t display well on the website they show like this � even thought I encoded in UTF-8.
I don’t know why this is happening. Help would be appreciated ! 🙂

#!/usr/bin/python

import sqlite3

print("Content-type: text/html; charset=UTF-8")


# Ecriture d'une page Web avec un formulaire
print('''
<html>
    <head>
        <meta charset="UTF-8">
        <title>Ajout Région</title>
        <link rel="stylesheet" href="style.css">
    </head>

    <body>
        <h1 style='text-align:center'>Ajouter une région</h1>

        <form method='get' action='insertionRegion.py'>
            Nom de la région : <input type='text' name='nomReg'/><br/>''')

print('''
            <br/>
            <input type='submit' value='Ajouter'/>
        </form>


        <hr/>
        <a href='index.py'>Retour au menu</a>

    </body>
</html>''')

PS : Sorry for my english.

Source: Python Questions

LEAVE A COMMENT