Skip to main content
4 of 6
I wanted to answer @DoMiNeLa10 in a comment but apparently I don't have the reputation for it so I stuck the answer as an edit

Problem with character encoding in Emacs 25

I am running Emacs 25 on Ubuntu 18.04. When I type accents, they display properly, but when I close and then reopen the file they appear like a backslash and then an octal number. This only happens with one particular file: all other files I process with Emacs on the same computer and same user account save and display accents fine. How is that possible? Whatever settings are contained in the .emacs config file would apply to all files? I've tried to set the coding system on the individual file that is causing problems, with the command set-buffer-file-coding-system and then selecting utf-8-unix, but I get the message: utf-8-unix cannot encode these: é

How can I fix the encoding of this file?

@DoMiNeLa10 Thanks for your reply. Nothing particular with file name, nor comments and the major mode is org-mode. What I suspect that has happened is that the problematic file has weird characters from copy/pastes from webpages. For instance, it contains the octal sequence \342\200\224 which on the original web page looks like a long dash. I suspect emacs doesn't know how to display it and then gets confused and gives up altogether trying to figure out the encoding; For instance, the file is full of the octal sequence \303\251 which is just accented é, that emacs should know how to display (as I said in my previous post I tried the command set-buffer-file-coding-system and then selected utf-8-unix, but it continues to display accents as octal sequences)

Is there a way to force emacs to use the utf-8-unix encoding to display accents correctly and just ignore the octal sequences that are not part of the encoding? I mean, I don't mind that the weird characters just remain octal sequences in the file, but I want to see the accents.

Thanks