Converts a sequence of encoded bytes into a set of characters. : Decoder « Development Class « C# / C Sharp






Converts a sequence of encoded bytes into a set of characters.

 

using System;
using System.Text;
public class dec
{
    public static void Main()
    {
        byte[] bytes1 = { 0x20, 0x23, 0xe2 };
        byte[] bytes2 = { 0x98, 0xa3 };
        char[] chars = new char[3];

        Decoder d = Encoding.UTF8.GetDecoder();
        int charLen = d.GetChars(bytes1, 0, bytes1.Length, chars, 0);
        charLen += d.GetChars(bytes2, 0, bytes2.Length, chars, charLen);
        foreach(char c in chars)
            Console.Write("U+{0:X4}  ", (ushort)c);
    }
}

   
  








Related examples in the same category

1.Create a new instance of the Decoder class.
2.Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.
3.Decode a sequence of bytes from the specified byte array