Returns a Unicode byte order mark encoded in UTF-8 format
using System;
using System.Text;
class UTF8EncodingExample {
public static void Main() {
UTF8Encoding UTF8NoPreamble = new UTF8Encoding();
UTF8Encoding UTF8WithPreamble = new UTF8Encoding(true);
Byte[] preamble;
preamble = UTF8NoPreamble.GetPreamble();
Console.WriteLine(" preamble length: {0}", preamble.Length);
ShowArray(preamble);
preamble = UTF8WithPreamble.GetPreamble();
Console.WriteLine(" preamble length: {0}", preamble.Length);
ShowArray(preamble);
}
public static void ShowArray(Array theArray) {
foreach (Object o in theArray) {
Console.Write("[{0}]", o);
}
}
}
Related examples in the same category