Reputation: 10142
Is there a way to have better conversion between unknown and known encodings? Currently, many valid characters are incorrectly shown as not encodeable.
Here is the problem I had:
I open a Latin-1 textfile and to my surprise, the coding system indicator is no longer 1
but =
meaning no-conversion. All non-ascii characters show as escapes.
So I try to set the coding system right by m3 on the coding system indicator telling that I want to use Latin-1 again.
Now, all non-ascii characters that happen to be valid Latin-1 codes are listed as not being able to be encoded (which is actually incorrect). That is very confusing.
In the end, I solved the problem by discovering a zero-byte somewhere in the file.
To reproduce:
Open a valid Latin-1 file with non-ascii characters and note the 1:
as coding system indicator.
Add C-@ (zero) somewhere in it. Probably more in the beginning
Save the file and kill the buffer.
Now reopen that file, and note that =:
is the coding system indicator
Now switch to Latin-1 and see the buffer *Warning*
showing you a list of the valid codes the system deems as inconvertible but not the one actual culprit since the list ends in ...
What I would expect is that only the zero-characters is shown.
(happens in Emacs 25 and 24 alike)
Upvotes: 0
Views: 148
Reputation: 28571
no-conversion
really means that the buffer is holding the underlying raw bytes rather than the intended characters. And when you change the coding-system to latin-1 you're not changing the buffer's content, you're just telling Emacs that you intend to use latin-1 to save the buffer to the file. So it complains about all the non-ASCII bytes because latin-1 does not know how to encode those bytes (it only encodes the chars that they are supposed to represent, i.e. it encodes them to those bytes).
What you want instead is to reload your file using the latin-1
(instead of no-conversion
) coding-system, which you can do with C-x RET r latin-1 RET
.
Maybe Emacs should offer to the user to revert the buffer when the buffer is unmodified and you're changing from no-conversion
to something else! I suggest you M-x report-emacs-bug
explaining how you found the interface confusing.
Upvotes: 2