WebName Property
Collapse the table of content
Expand the table of content

Encoding.WebName Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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 Windows Phone.

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.


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


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2016 Microsoft