Big Endian Unicode Bytes : Encoding Unicode « I18N Internationalization « C# / CSharp Tutorial





using System;
using System.Text;

public class MainClass
{
    static void Main() {
        string str = "abc!";
        
        Encoding unicode = Encoding.Unicode;
        Encoding beUnicode = Encoding.BigEndianUnicode;
        
        byte[] unicodeBytes = unicode.GetBytes(str);
        
        byte[] beUnicodeBytes = Encoding.Convert( unicode,
                                                  beUnicode,
                                                  unicodeBytes);
        Console.WriteLine( "Big Endian Unicode Bytes:" );
        StringBuilder sb = new StringBuilder();
        foreach( byte b in beUnicodeBytes ) {
            sb.Append( b ).Append(" : ");
        }
        Console.WriteLine( "{0}\n", sb.ToString() );
        
    }
}
Big Endian Unicode Bytes:
0 : 97 : 0 : 98 : 0 : 99 : 0 : 33 :










21.12.Encoding Unicode
21.12.1.Unicode encode
21.12.2.Big Endian Unicode Bytes
21.12.3.Convert UTF8 from Unicode
21.12.4.Encodings: Encoding.GetEncoding(1252)
21.12.5.Use UnicodeEncoding to encode and decode char array