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