Mega Code Archive

 
Categories / C# / Development Class
 

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);     } }