Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Some internet addresses are html encoded and I want to decode to normal strings. For example http%3A%3D%3Dgoogle%2Ecom to http://google.com. How can I do simply?
Posted

1 solution

If you use .NET 4.5:
C#
using System.Net; // add this at the top of your code file
// the code to decode:
string input = "http%3A%3D%3Dgoogle%2Ecom";
string decoded = WebUtility.UrlDecode(input);

The WebUtility class doesn't exist in older versions, so if you use an older .NET version, add a reference to System.Web and use this code:
C#
using System.Web; // add this at the top of your code file
// the code to decode:
string input = "http%3A%3D%3Dgoogle%2Ecom";
string decoded = HttpUtility.UrlDecode(input);

Note: the above code transforms it into http:==google.com and not http://google.com, because %3D doesn't represent a slash. Use %2F if you want a slash.
 
Share this answer
 
Comments
BillWoodruff 22-Nov-14 10:52am    
+5
Thomas Daniels 22-Nov-14 11:11am    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900