C# UTF8Encoding UTF8Encoding(Boolean)
Description
UTF8Encoding UTF8Encoding(Boolean)
Initializes a
new instance of the UTF8Encoding class. A parameter specifies whether to
provide a Unicode byte order mark.
Syntax
UTF8Encoding.UTF8Encoding(Boolean)
has the following syntax.
public UTF8Encoding(
bool encoderShouldEmitUTF8Identifier
)
Parameters
UTF8Encoding.UTF8Encoding(Boolean)
has the following parameters.
encoderShouldEmitUTF8Identifier
- true to specify that a Unicode byte order mark is provided; otherwise, false.
Example
using System;/*from w w w . java 2 s.c o m*/
using System.Text;
class UTF8EncodingExample {
public static void Main() {
UTF8Encoding utf8 = new UTF8Encoding();
UTF8Encoding utf8EmitBOM = new UTF8Encoding(true);
ShowArray(utf8.GetPreamble());
ShowArray(utf8EmitBOM.GetPreamble());
}
public static void ShowArray(Array theArray) {
foreach (Object o in theArray) {
Console.Write("[{0}]", o);
}
Console.WriteLine();
}
}
The code above generates the following result.