Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Html Encoding and Decoding

Total Hit ( 6650)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Some time you need funky code don't bother yourself by hard coding to every things when Microsoft give you facility.
Simply add refreces of System.Web to your project then where you need Encoding write this line
System.Web.HttpUtility.HtmlEncode()

Sample example

Click here to copy the following block
string StringWantToEncode ="Hello buddies";
string EncodedString =System.Web.HttpUtility.HtmlEncode(System.Web.HttpUtility.HtmlEncode());

and Decoding is simple as Encoding only the function name is diffrent
HttpUtility.HtmlDecode()

The code that I was using before knowing HttpUtility Class is below


private string ConvertToASCII(string val)
    {
      string[] split = val.Split(new char[] { ';' });
      StringBuilder sb =new StringBuilder();
      string ReturnValue = "";
      foreach (string st in split)
      {
        string st2 = st.Replace("&#", "");
        if (st2 != String.Empty)
        {

          int i = 0;
          int.TryParse(st2, out i);
          char ch = Convert.ToChar(i);
          sb.Append(ch);
        }
      }
      ReturnValue = sb.ToString();
      return ReturnValue;
    }

Sample Input : 

hous-wkvz3-1122845765@craigslist.org
Sample out : Check by your self


Submitted By : nido khan  (Member Since : 4/16/2009 1:57:42 AM)

Job Description :
View all (1) submissions by this author  (Birth Date : )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.