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.
@Stefan: the output of checking:
M-L buffer-file-coding-system RET
buffer-file-coding-system is a variable defined in ‘C source code’. Its value is ‘no-conversion’ Local in buffer todo1.org; global value is utf-8-unix Automatically becomes buffer-local when set.
C-x RET r utf-8 RET as you suggested and it works well, displaying all accents correctly instead of backslash octal sequences and the
buffer-file-coding-system value becomes
utf-8, but if I close the file and then open again, the backslash octal mess reappears and the value reverts to '
ctrl-c to copy from firefox and
ctrl-y to paste in emacs. Sometimes, I just select in firefox and then middle-click mouse button to paste. Maybe pasting with the middle-click mouse button is the cause of the problem?