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();
        }
    }

}


posted @ 2018-07-11 13:03  dxm809  阅读(128)  评论(0编辑  收藏  举报