MVC HttpUtility.HtmlEncode是如何编码的
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace HttpUtilityDemo
{
class Program
{
static void Main(string[] args)
{
String myString;
Console.WriteLine("Enter a string having '&' or '\"' in it: ");
myString = Console.ReadLine();
String myEncodedString;
// Encode the string.
myEncodedString = HttpUtility.HtmlEncode(myString);
Console.WriteLine("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());
Console.Read();
}
}
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace HttpUtilityDemo
{
class Program
{
static void Main(string[] args)
{
String myString;
Console.WriteLine("Enter a string having '&' or '\"' in it: ");
myString = Console.ReadLine();
String myEncodedString;
// Encode the string.
myEncodedString = HttpUtility.HtmlEncode(myString);
Console.WriteLine("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());
Console.Read();
}
}
}