C# UTF8Encoding GetChars(Byte[])

Description

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

Syntax

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


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

Parameters

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

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

Returns

UTF8Encoding.GetChars(Byte[]) method returns

Example


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

public class SamplesEncoding
{

    public static void Main()
    {
        Encoding u32LE = Encoding.GetEncoding("utf-32");

        String myStr = "za\u0306\u01FD\u03B2";

        byte[] barrLE = new byte[u32LE.GetByteCount(myStr)];
        u32LE.GetBytes(myStr, 0, myStr.Length, barrLE, 0);

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

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding