How to switch back text encoding to UTF-8 with emacs?

If you haven't changed the file, you can try M-x revert-buffer-with-coding-system. One of latin-1 or utf-8 should work, depending on the file.

You can also mark the entire file with C-x h and then try M-x recode-region. It will ask you for Text was really in and But was interpreted as. For the first file in your question, it looks like it should be latin-1 and utf-8, and for the second example it should probably be the other way around, utf-8 and latin-1.

After you got it right, you can choose which coding system to save the file with using M-x set-buffer-file-coding-system (or C-x C-m f for short).


The easiest way I've found is:

C-x RET r utf-8 RET


I tried the top answer above, but it didn't quite entirely fix my problem. So to add onto that...

If the problem persists when you re-open the file, it could also be due to the variable enable-multibyte-characters being nil.

A new buffer will usually have this as t (which is why you can paste utf-8 characters into the buffer hassle-free).

To fix this, you'll need to do something like: (set-buffer-multibyte 't)

The result should be instantaneous.