C# Encoding GetChars(Byte[], Int32, Int32)

Description

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

Syntax

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


public virtual char[] GetChars(
  byte[] bytes,/*  w  ww. j av a2s  . c o m*/
  int index,
  int count
)

Parameters

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

  • bytes - The byte array containing the sequence of bytes to decode.
  • index - The index of the first byte to decode.
  • count - The number of bytes to decode.

Returns

Encoding.GetChars(Byte[], Int32, Int32) method returns

Example


using System;/*from w  ww  .  java2  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, 0, 8);
        Console.WriteLine(chars);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding