C# ASCIIEncoding GetChars(Byte[])

Description

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

Syntax

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


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

Parameters

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

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

Returns

ASCIIEncoding.GetChars(Byte[]) method returns

Example


/*from  w w w .  ja  va 2  s  . com*/
using System;
using System.Text;

public class SamplesEncoding
{

    public static void Main()
    {
        Encoding enc = Encoding.GetEncoding("utf-32");
        Encoding u32BE = Encoding.GetEncoding("utf-32BE");
        String myStr = "za\u0306\u01FD\u03B2";


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

        Console.Write("{0,-25} :", enc.ToString());

        int iCC = enc.GetCharCount(bytes);
        Console.Write(" {0,-3}", iCC);

        int iMCC = enc.GetMaxCharCount(bytes.Length);
        Console.Write(" {0,-3} :", iMCC);

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

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding