Skip to main content

How to convert special characters to HTML encoded equivalents using C#.NET

public string HTMLEncodeSpecialChars(string text)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
foreach (char c in text){
if(c>127) // special chars
sb.Append(String.Format("&#{0};",(int)c));
else
sb.Append(c);
}
return sb.ToString();
}

Comments

  1. Hey I know this is off topic but I was wondering if you knew of any widgets I could add
    to my blog that automatically tweet my newest twitter updates.
    I've been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

    Take a look at my webpage: luxe vakantiehuizen ()

    ReplyDelete
  2. I used to be recommended this web site by means of my cousin.
    I am not sure whether or not this post is written by way of him
    as nobody else realize such distinct approximately my difficulty.
    You are incredible! Thank you!

    my web site ... vakantiehuisjes frankrijk []

    ReplyDelete
  3. You could certainly see your expertise within the article you write.
    The world hopes for even more passionate writers such as you who are
    not afraid to mention how they believe. Always go after your heart.


    Here is my blog post :: vakantiehuisjes - -

    ReplyDelete

Post a Comment

Popular posts from this blog

pligg_validate does not return correct value

Pligg version 1.0.3 Before function pligg_validate(){ // returns the value for register validation return misc_validate; } After function pligg_validate(){ // returns the value for register validation global $db; $sql = "SELECT `var_value` FROM `" . table_config . "` WHERE `var_name` = '" . $db->escape('misc_validate') . "';"; $misc_validate = $db->get_var($sql); return return trim($misc_validate)=="true"?true:false; }

Wrong Referrer with Pligg

To debug the problem, edit /libs/html1.php, find the function check_referrer(). To fix this issue, replace $my_base_url value to ' http://localhost ' as the following code. $my_base_url = ' http://localhost '; $my_pligg_base = ''; $dblang = 'en'; define('table_prefix', 'pligg_'); $language = 'english'; include_once mnminclude.'settings_from_db.php';