I was working on a eLearning tool which supports various Learning Management Systems. Out of those one of the LMSs require files written in UTF8 encoding without Byte Order Mark(BOM).
If you are using Notepad++, you will find such type of encoding scheme over there. I was writing this piece of code in VB.Net.
The below code illustrates how to write files omitting BOM.
If you are using Notepad++, you will find such type of encoding scheme over there. I was writing this piece of code in VB.Net.
The below code illustrates how to write files omitting BOM.
There seems to be a way of omitting the byte order mark (BOM) via passing
That is, use your own instance of
False
True
to the UTF8Encoding constructor (link to MSDN reference page).That is, use your own instance of
UTF8Encoding
instead of the default System.Text.Encoding.UTF8
:Dim utf8WithoutBom As New System.Text.UTF8Encoding(True) '^^^^' Using sink As New StreamWriter("Foobar.txt", False, utf8WithoutBom) sink.WriteLine("...") End Using(Note that omitting the BOM is only permissible for UTF-8, not for UTF-16.)