C# UTF8Encoding WebName

Description

UTF8Encoding WebName When overridden in a derived class, gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.

Syntax

UTF8Encoding.WebName has the following syntax.


public virtual string WebName { get; }

Example

The following example includes the WebName.


//from w  w w. j  a  va  2s  . c om
using System;
using System.IO;
using System.Text;
using System.Web;

public class ExampleClass 
{
   public static void Main(string[] args) 
   {
       Encoding encoding = Encoding.UTF8;
    
       Console.WriteLine("<html><head>");
       Console.WriteLine("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=" +
                               encoding.WebName +"\">");
      
         Console.WriteLine("</head><body>");
       Console.WriteLine("<p>" + HttpUtility.HtmlEncode(encoding.EncodingName) + "</p>");
       Console.WriteLine("</body></html>");

   }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding