Convert UTF8 from Unicode
using System;
using System.Text;
public class MainClass
{
static void Main() {
string str = "abc!";
Encoding unicode = Encoding.Unicode;
Encoding utf8 = Encoding.UTF8;
byte[] unicodeBytes = unicode.GetBytes(str);
byte[] utf8Bytes = Encoding.Convert( unicode,
utf8,
unicodeBytes );
Console.WriteLine( "UTF Bytes:" );
StringBuilder sb = new StringBuilder();
foreach( byte b in utf8Bytes ) {
sb.Append( b ).Append(" : ");
}
Console.WriteLine( sb.ToString() );
}
}
Output UTF Bytes:
97 : 98 : 99 : 33 :
|
HTML code for linking to this page:
Related in same category :
-
-
-
|