Here’s how to control whether or not the utf-8 preamble is included in your file I/O when writing strings to a file (in C#):
string s = "This is a test éééé";
// Write a string as utf-8 to a file without the 3-byte utf-8 preamble.
System.Text.Encoding utf8EncoderNoBOM = new System.Text.UTF8Encoding(false);
bool appendMode = false; // This overwrites the entire file.
StreamWriter sw = new StreamWriter("out_utf8_noPreamble.txt",
appendMode,utf8EncoderNoBOM);
sw.Write(s);
sw.Close();
// Write the file with the utf-8 preamble:
StreamWriter sw2 = new StreamWriter("out_utf8_withPreamble.txt",
appendMode, System.Text.Encoding.UTF8);
sw2.Write(s);
sw2.Close();