Write the UTF-16 encoded bytes of the source string : Unicode UTF16 : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Unicode UTF16 »

 

Write the UTF-16 encoded bytes of the source string









    

using System;
using System.IO;
using System.Text;

class Test
{
    public static void Main() 
    {        
        using (StreamWriter output = new StreamWriter("practice.txt")) 
        {
            // Create and write a string containing the symbol for Pi.
            string srcString = "Area = \u03A0r^2";

            // Write the UTF-16 encoded bytes of the source string.
            byte[] utf16String = Encoding.Unicode.GetBytes(srcString);
            output.WriteLine("UTF-16 Bytes: {0}", BitConverter.ToString(utf16String));
            Console.WriteLine(BitConverter.ToString(utf16String));
        }
    }
}




           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Unicode UTF16