Generating UTF-8 without BOM(Byte Order Mark)

I am generating a file in UTF-8 File format. When i open my file through notepad, i can see only my data. But a 3 byte sequence BOM (Byte Order Mark) is getting added at the beginning of the file to indicate that it is UTF-8 file format which is invisible. If i open the file through command prompt, i can see that 3 bytes.


My requirement is that , i don’t want that 3 byte sequence BOM at the beginning of the file but my file should be in UTF-8 file format.

Is there any way to remove the Byte order mark through X++ code

Thanks & Regards

Arun B S

Here is my Job

static void bank_test(Args _args)


FileName fileName;

InteropPermission iopermission;

Textio txioWrite;




fileName = “C:\Documents and Settings\abs\Desktop\test.CSV”;

iopermission = new InteropPermission(InteropKind::ClrInterop);


txioWrite = new Textio(fileName,#write,#UTF8Code); // #UTF8Code is to generate a file in UTF-8 format

txioWrite.write(“Data 123”);

txioWrite = null;



Answered in a parallel thread on another forum.

Quoting the most important part:

If you use .NET, you can exclude BOM by using properly configured UTF8Encoding. It’s done by the parameter of UTF8Encoding’s constructor in the following example (written in X++ using .NET Interop):

<i>System.Text.Encoding encoding = new System.Text.UTF8Encoding(false);
System.IO.File::WriteAllText(@'C:\test.txt', "Data 123", encoding);</i>