Topics include: programming, Apple, Unix, gadgets, large-scale web sites and other nerdy stuff.

set emacs coding system

2006-08-08 13:07:00

Every now and then I try to create a new XML file in emacs. It's something I don't do that much, because I hate XML. Hate it. But that's a rant for another day.

The problem I run into is that when you make a new buffer in emacs, it sets the default encoding scheme to iso-latin-1. And, of course, XML is (by definition) utf-8. Emacs tries to be all helpful and says "hey billo you idiot, iso-latin-1 is wrong. change it." Naturally, it doesn't tell me how to change it. So I always waste time trying to remember how to fix the encoding. Since I can't remember anything, I'm writing this note so I can waste less time in the future. I hope I remember I wrote this note.

The solution is:

M-x set-buffer-file-coding-system

Answer: utf-8