views:

521

answers:

4

I know this is not a "real" programming question. But, it relates to programming so I am going to set it anyway. I have a program that I need to test that reads the Byte Order Marker of the file to see if it is utf-8 or utf-16. My problem is I cannot find a program/text editor that will allow me to set the byte order marker. Can anybody tell me how to set this in a text file?

+3  A: 

If you need to be absolutely sure what's going on, create the files in binary, either using a binary hex editor or writing it out from a program.

Jon Skeet
+1  A: 

Ultra Edit or Notepad++ should both be able to do it, and edit the raw hex too (via a plugin with np++)

Greg
+1  A: 

You should be able to see and edit this in Visual Studio.NET if you have it.

Bring up the open file dialog in Visual Studio. Click the little triangle on the Open button, and select Open With. Now select binary editor.

You should be able to edit the hex values at the beginning of the file to include any byte order pattern you need.

This Wikipedia article describes what you will need to set the byte order markers to be for the different file formats (UTF-8 or UTF-16 for example)

John Sibly
+2  A: 

There is a pretty good program called BabelPad. It will not only set the BOM, I believe it will also tel you if it is set or not. You can also do it programmitically in .Net. There is a good FAQ about this on MSN.

Matt Brown