Export (0) Print
Expand All

Encoding.WebName Property

Gets the name registered with the Internet Assigned Numbers Authority (IANA) for this encoding.

[Visual Basic]
Public Overridable ReadOnly Property WebName As String
[C#]
public virtual string WebName {get;}
[C++]
public: __property virtual String* get_WebName();
[JScript]
public function get WebName() : String;

Property Value

The IANA name for this encoding.

Example

[Visual Basic] 
Imports System
Imports System.IO
Imports System.Text
Imports System.Web

Namespace WebNameExample
   Public Class ExampleClass
      
      Public Overloads Shared Sub Main()
         ' Use UTF8 encoding.
         Dim encoding As Encoding = Encoding.UTF8
         Dim writer As New StreamWriter("Encoding.html", False, encoding)
         
         writer.WriteLine("<html><head>")
         
         ' Write charset attribute to the html file.
         writer.Write("<META HTTP-EQUIV=""Content-Type"" CONTENT=""text/html;")
         writer.WriteLine(" charset=" + encoding.WebName + """>")
         
         writer.WriteLine("</head><body>")
         writer.WriteLine("<p>" + HttpUtility.HtmlEncode(encoding.EncodingName) + "</p>")
         writer.WriteLine("</body></html>")
         writer.Flush()
         writer.Close()
      End Sub
   End Class
End Namespace

[C#] 
using System;
using System.IO;
using System.Text;
using System.Web;

namespace WebNameExample 
{
   public class ExampleClass 
   {
      public static void Main(string[] args) 
      {
         // Use UTF8 encoding.
     Encoding encoding = Encoding.UTF8;
     StreamWriter writer = new StreamWriter("Encoding.html", false, encoding);
             
     writer.WriteLine("<html><head>");

     // Write charset attribute to the html file.
     // The value of charset is returned by the WebName property.
     writer.WriteLine("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=" +
                           encoding.WebName +"\">");
    
         writer.WriteLine("</head><body>");
     writer.WriteLine("<p>" + HttpUtility.HtmlEncode(encoding.EncodingName) + "</p>");
     writer.WriteLine("</body></html>");
     writer.Flush();
     writer.Close();
      }
   }
}

[C++] 
#using <mscorlib.dll>
#using <System.dll>
#using <System.Web.dll>
using namespace System;
using namespace System::IO;
using namespace System::Text;
using namespace System::Web;

int main()
{
   // Use UTF8 encoding.
   Encoding * encoding = Encoding::UTF8;
   StreamWriter* writer = new StreamWriter(S"Encoding.html", false, encoding);
   writer -> WriteLine(S"<html><head>");
   
   // Write charset attribute to the html file.
   // writer -> WriteLine(S"<META HTTP-EQUIV=\"Content-Type\S" CONTENT=\"text/html; charset=S {0}", encoding.WebName +"\S">");
   writer -> WriteLine(String::Concat(S"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=", encoding->WebName, S"\">"));
   
   writer -> WriteLine(S"</head><body>");
   writer -> WriteLine(S"<p>{0}</p>", HttpUtility::HtmlEncode(encoding -> EncodingName));
   writer -> WriteLine(S"</body></html>");
   writer -> Flush();
   writer -> Close();
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Encoding Class | Encoding Members | System.Text Namespace

Show:
© 2015 Microsoft