Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array. : Decoder « Development Class « C# / C Sharp






Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.

 

using System;
using System.Text;

class DecoderExample {
    public static void Main() {
        Byte[] bytes = new Byte[] {5, 0, 10, 0, 105, 0, 99, 0, 111, 0, 100, 0, 101, 0};

        Decoder uniDecoder = Encoding.Unicode.GetDecoder();
        int charCount = uniDecoder.GetCharCount(bytes, 0, bytes.Length);
        Console.WriteLine("{0} characters needed to decode bytes.", charCount);
    }
}

   
  








Related examples in the same category

1.Converts a sequence of encoded bytes into a set of characters.
2.Create a new instance of the Decoder class.
3.Decode a sequence of bytes from the specified byte array