Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Encoding.WebName Property

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

Namespace:  System.Text
Assembly:  mscorlib (in mscorlib.dll)

public virtual string WebName { get; }

Property Value

Type: System.String
The IANA name for the current Encoding.

The WebName property returns an IANA-registered name for the encoding. It returns the strings shown in the following table for the encodings supported by Silverlight.

Encoding

WebName property value

UTF8

utf-8

Unicode

utf-16

BigEndianUnicode

utf-16BE

The following example displays the WebName property for each of the encodings supported by the .NET Framework for Silverlight.


using System;
using System.Text;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      string encodingName;

      // Get UTF8 encoding object.
      Encoding enc8 = Encoding.UTF8;
      encodingName = enc8.WebName;
      outputBlock.Text += String.Format("{0}: {1}\n", enc8.ToString(), enc8.WebName);
      outputBlock.Text += enc8.Equals(Encoding.GetEncoding(encodingName)) + "\n";

      // Get UTF16 encoding object.
      Encoding enc16 = Encoding.Unicode;
      encodingName = enc16.WebName;
      outputBlock.Text += String.Format("{0}: {1}\n", enc16.ToString(), enc16.WebName);
      outputBlock.Text += enc16.Equals(Encoding.GetEncoding(encodingName)) + "\n";

      // Get UTF16 big endian encoding object.
      enc16 = Encoding.BigEndianUnicode;
      encodingName = enc16.WebName;
      outputBlock.Text += String.Format("{0}: {1}\n", enc16.ToString(), enc16.WebName);
      outputBlock.Text += enc16.Equals(Encoding.GetEncoding(encodingName)) + "\n";
   }
}
// The example displays the following output:
//     System.Text.UTF8Encoding: utf-8
//     True
//     System.Text.UnicodeEncoding: utf-16
//     True
//     system.Text.UnicodeEncoding: utf-16BE
//     True


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2015 Microsoft