开发者

Removing byte-order marks (BOMs) using Emacs

开发者 https://www.devze.com 2023-01-19 03:53 出处:网络
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.

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消