Byte Order Marks and Emacs

Some programs write byte order marks into their output files, even when they are encoded in UTF-8. When opening such file in Emacs in the ordinary way these byte order marks are correctly interpreted and removed from the contents that are displayed to the user.

However, these byte order marks can trip up other programs which do not understand them. In some programs they will appear as  while in others they will cause syntax errors or, even worse, difficult to diagnose problems in their output. I was caught out in PDFLatex which was printing an extra empty page at the beginning of the document due to these byte order marks.

So it is useful to sometimes see these marks in Emacs in order to resolve potential problems. This can be done using the find-file-literally Emacs function which will not do the usual conversions when opening a file. (If you already have this file open, remember to kill that buffer and re-open the file).

The byte order marks will be visible as an initial sequence that prints as "\357\273\277" and they can be removed from the file simply by deleting them and saving the file.