GNU bug report logs -
#58507
Emacs does not preserve the coding system
Previous Next
Reported by: Juhana Sadeharju <johanrainhill <at> gmail.com>
Date: Fri, 14 Oct 2022 09:45:01 UTC
Severity: normal
Tags: moreinfo, notabug
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #22 received at 58507 <at> debbugs.gnu.org (full text, mbox):
> From: Juhana Sadeharju <johanrainhill <at> gmail.com>
> Date: Thu, 9 Feb 2023 10:56:22 +0200
>
> Hello. Has this bug or feature been fixed?
We made no change to Emacs due to this report, since I don't believe
there's a bug here. This is how Emacs behaves, and this behavior is
well documented and intended.
In previous discussion of this issue, I pointed out how to deal with
such situations; I repeat some of that below.
> The problem is that Emacs doesn't keep the coding system I have
> set (utf-8).
The information about the file's encoding, if you want to keep it,
should be in the file, using the 'coding:' cookie, by adding
";;; -*- coding: utf-8-dos; -*-"
in the first line of the file. (You can also do this in the file's
Local Variables section near the end of the file; see the "Specifying
File Variables" node of the Emacs user manual for details.
Alternatively, you can force Emacs to use UTF-8 when you visit the
file:
C-x RET c utf-8 RET C-x C-f <file name> RET
The "C-x RET c utf-8 RET" prefix forces the following command to use
UTF-8 for decoding and encoding text.
> The file is opened with different coding system and all รครถ chars are a mess. Even I set the coding
> system again to utf-8, all the mess remains. Fixing the mess does not help because the next time the coding
> system is wrong again.
>
> Why Emacs doesn't let user to decide what is the coding system for the file?
It does, see above.
> I'm actually scared to use Emacs anymore because Emacs has converted thousands lines of text to a
> mess because of this bug.
As long as you only visit the file and don't make any changes to it,
the "mess" on the screen is just a display problem; the file's
contents is not changed.
> There was a trick to fix the coding system by inserting commands to the start of file, so I suggest to add a
> command like "fix the coding system to file" which adds the trick thing to the file. I keep forgetting the trick.
The command is "C-x RET r". This re-reads the file after prompting
you for the coding-system to decode the file's contents. Which is yet
another alternative to "fix" the problem after you visit the file and
notice the incorrect guess of its coding-system.
This bug report was last modified 1 year and 257 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.