C# Encoding GetChars(Byte[])

Description

Encoding GetChars(Byte[]) When overridden in a derived class, decodes all the bytes in the specified byte array into a set of characters.

Syntax

Encoding.GetChars(Byte[]) has the following syntax.


public virtual char[] GetChars(
  byte[] bytes
)

Parameters

Encoding.GetChars(Byte[]) has the following parameters.

  • bytes - The byte array containing the sequence of bytes to decode.

Returns

Encoding.GetChars(Byte[]) method returns

Example


using System;/*ww  w .  ja va 2 s .  co m*/
using System.Text;

public class SamplesEncoding
{

    public static void Main()
    {
        Encoding enc = Encoding.GetEncoding("utf-32BE");
        String myStr = "za\u0306\u01FD\u03B2";
        byte[] barrLE = new byte[enc.GetByteCount(myStr)];
        enc.GetBytes(myStr, 0, myStr.Length, barrLE, 0);

        char[] chars = enc.GetChars(barrLE);
        Console.WriteLine(chars);
    }
}




















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding