Unicode encode : Encoding Unicode : I18N Internationalization C# Examples


C# Examples » I18N Internationalization » Encoding Unicode »

 

Unicode encode









    
using  System;
using  System.Text;

public  class  MainClass
{
        static  void  Main()  {
                string  str  =  "abc!";
                
                Encoding  unicode  =  Encoding.Unicode;
                
                byte[]  unicodeBytes  =  unicode.GetBytes(str);
                
                Console.WriteLine(  "Orig.  String:  {0}\n",  str  );
                Console.WriteLine(  "Little  Endian  Unicode  Bytes:"  );
                StringBuilder  sb  =  new  StringBuilder();
                foreach(  byte  b  in  unicodeBytes  )  {
                        sb.Append(  b  ).Append("  :  ");
                }
                Console.WriteLine(  "{0}\n",  sb.ToString()  );
                
        }
}
    
   
  
   



Output

Orig. String: abc!

Little Endian Unicode Bytes:
97 : 0 : 98 : 0 : 99 : 0 : 33 : 0 :


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo I18N Internationalization
» Encoding Unicode