Posted By


dactivo on 05/04/11

Tagged


Statistics


Viewed 136 times
Favorited by 0 user(s)

HTMLEncodeSpecialChars


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public string HTMLEncodeSpecialChars(string text)
  2. {
  3. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  4. foreach (char c in text){
  5. if(c>127) // special chars
  6. sb.Append(String.Format("&#{0};",(int)c));
  7. else
  8. sb.Append(c);
  9. }
  10. return sb.ToString();
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.