Bonjour à tous.
J'utilise actuellement cette fonction (récupérée sur le forum) pour l'encodage en caractère html:
Code C# :
//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 é
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