Example

 using System; using System.Text; namespace Samples { public class UnicodeEncodingSample { public static void Main() { UnicodeEncoding u = (UnicodeEncoding) Encoding.Unicode; string s = "Pi is (\u03a0)"; int count = u.GetByteCount(s); Console.WriteLine("In string"); foreach(Int16 i in s) Console.Write("{0}, ", i); Console.WriteLine(); byte[] bytes = new byte[count]; bytes = u.GetBytes(s); Console.WriteLine("Converted to array of bytes"); foreach(Byte b in bytes) Console.Write("{0}, ", b); Console.WriteLine(); count = u.GetCharCount(bytes); char[] chars = new char[count]; u.GetChars(bytes, 0, bytes.Length, chars, 0); Console.WriteLine("Converted to array of chars"); foreach(Int16 c in chars) Console.Write("{0}, ", c); Console.WriteLine(); ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.