| |||||
HttpUtility.HtmlDecode MethodSystem.Web Namespace HttpUtility Class Converts a string that has been HTML-encoded for HTTP transmission into a decoded string. Overload List1. Converts a string that has been HTML-encoded for HTTP transmission into a decoded string. 2. Converts a string that has been HTML-encoded into a decoded string, and sends the decoded string to a TextWriter output stream. ExampleThe following example demonstrates the HtmlEncode and HtmlDecode methods of the HttpUtility class. The input string is taken from user and encoded using the HtmlEncode method.The encoded string thus obtained is then decoded using the HtmlDecode method.
[ VB ] Imports System Imports System.Web Imports System.IO Class myNewClass Public Shared Sub Main ( ) Dim myString As String Response.Write ( "Enter a string having '&' or '""' in it: " ) myString = Console.ReadLine ( ) Dim myEncodedString As String ' Encode the string. myEncodedString = HttpUtility.HtmlEncode ( myString ) Response.Write ( "HTML Encoded string is " + myEncodedString ) Dim myWriter As New StringWriter ( ) ' Decode the encoded string. HttpUtility.HtmlDecode ( myEncodedString, myWriter ) Console.Write ( "Decoded string of the above encoded string is " &_ myWriter.ToString ( ) ) End Sub End Class [ C# ] using System; using System.Web; using System.IO; class myNewClass { public static void Main ( ) { String myString; Response.Write ( "Enter a string having '&' or '\"' in it: " ); myString=Console.ReadLine ( ); String myEncodedString; // Encode the string. myEncodedString = HttpUtility.HtmlEncode ( myString ); Response.Write ( "HTML Encoded string is "+myEncodedString ); StringWriter myWriter = new StringWriter ( ); // Decode the encoded string. HttpUtility.HtmlDecode ( myEncodedString, myWriter ); Console.Write ( "Decoded string of the above encoded string is " + myWriter.ToString ( ) ); } } See Also |
| ||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme