Bonjour à tous.

J'utilise actuellement cette fonction (récupérée sur le forum) pour l'encodage en caractère html:


Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//encode a string in Html to avoid problems with accents
        public static string HtmlEncode(string text)
        {
            char[] chars = HttpUtility.HtmlEncode(text).ToCharArray();
            StringBuilder result = new StringBuilder(text.Length + (int)(text.Length * 0.1));
 
            foreach (char c in chars)
            {
                int value = Convert.ToInt32(c);
                if (value > 127)
                    result.AppendFormat("&#{0};", value);
                else
                    result.Append(c);
            }
 
            return result.ToString();
        }



Ce que je cherche à faire, c'est par exemple transformer :
é en &eacute
espace en  
etc...

Pour le é, ma fonction me renvoie é au lieu de é


Est-ce normal ? Comment modifier ma fonction pour arriver à faire cela ?



Merci d'avance,

Romain