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

Description

UTF8Encoding 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

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


public virtual char[] GetChars(
  byte[] bytes,//from  w w  w  .j  a v  a  2  s  . com
  int index,
  int count
)

Parameters

UTF8Encoding.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

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

Example


using System;/*from www  .  j a va 2 s.c  o  m*/
using System.Text;

public class SamplesEncoding
{

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

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

        byte[] barrBE = new byte[u32BE.GetByteCount(myStr)];
        u32BE.GetBytes(myStr, 0, myStr.Length, barrBE, 0);

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


    }

}




















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding