tags:

views:

86

answers:

1

I have a file containing UTF-8 encoded text with a byte-order mark. This BOM is getting in the way of things, and I'd like to remove it.

Resorting to either other tools, such as perl or awk, or weird editing modes, such as hexl-mode, every time I want to get rid of a BOM is somewhat annoying.

Is there a way to tell Emacs to remove the existing BOM and not to write it out to disk again on subsequent saves?

+5  A: 

Setting coding-system-for-write directly is a bit of a hack. The user command for changing a file's encoding (in this case from utf-8-with-signature to plain utf-8) is set-buffer-file-coding-system. It is bound by default to C-x RET f.

JSON