C# Encoding Unicode

Description

Encoding Unicode Gets an encoding for the UTF-16 format using the little endian byte order.

Syntax

Encoding.Unicode has the following syntax.


public static Encoding Unicode { get; }

Example


using System;//from   w w  w . j a  v  a 2s . c om
using System.Text;

public class Example
{
    public static void Main()
    {
        byte[] bytes = { 0x20, 0x00, 0x01, 0xD8, 0x68, 0x00, 0xA7, 0x00 };
        Encoding enc = new UnicodeEncoding(false, true, true);

        string value = enc.GetString(bytes);
        Console.WriteLine(value);

        char[] myChars = new char[] { 'z', 'a', '\u0306', '\u01FD', '\u03B2', '\uD8FF', '\uDCFF' };

         enc = Encoding.Unicode;
        Console.Write("{0,-30} :", enc.ToString());
    }
}




















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding