From: david.madore@ens.fr (David Madore)
Subject: getting out of raw-text encoding
Date: 10 May 2003 15:21:08 GMT [thread overview]
Message-ID: <b9j5d4$rlf$1@nef.ens.fr> (raw)
Hi!
This is with (FSF) Emacs 21.2, compiled with LEIM. (Though I suppose
the actual Emacs version makes little difference.)
Suppose I have a file which is *mostly* encoded in the iso-8859-1
character set. However, it has a few occasional characters that are
not iso-8859-1. For example, it might be actually in the windows-1252
character set (that closely resembles iso-8859-1 but adds 32 extra
characters, with codes from 128 through 159). A sample could be
produced with
perl -e 'for ($i=32;$i<256;$i++) { print chr($i); } print "\n";' >file
for instance.
When I open the file with Emacs, it quite rightfully detects that it
is not iso-8859-1, and switches to raw-text encoding (non-ASCII
characters are represented by escape sequences). Now suppose I don't
like that.
I can force the file to be reinterpreted as iso-8859-1 by killing the
buffer and reopening it with C-x RET c iso-8859-1 as prefix.
Basically this does what I want, but suppose I wish to do it without
closing and reopening the file (there may be reasons for this, e.g.,
if the buffer is actually not a file I opened but something that was
produced by an Emacs submodule, like Gnus in attempting to reply to a
news post with a bad encoding).
So what I wish is, to change every raw-text octet value that makes
sense as an iso-8859-1 character by that corresponding character. I
hope I'm using the correct terminology here.
First of all, doing C-x RET c iso-8859-1 M-x revert-buffer does not
work (it does not do anything, in fact, apparently). Nor do I
understand why. But even if it did, it still wouldn't be what I like,
because it would force the buffer to have an associated file.
Usually, when I need to reinterpret using the <bar> encoding a file
that has been read using the <foo> encoding by mistake (typical
example would be when <bar>=utf-8 and <foo>=iso-8859-1) I can do this:
C-x h M-x encode-coding-region <foo> M-x decode-coding-region <bar>
which works by first forcing the buffer back to the octets that encode
it in the <foo> encoding, and then decoding these octets using the
<bar> encoding. However, when <foo> is raw-text, this does not
function as I expect it (maybe I'm being entirely naive there?), for
the encode-coding-region command does not do anything, and the
decode-coding-region merely adds more junk in front of my escaped
characters.
So, basically, how do I get out of raw-text without killing the
buffer?
Incidentally, is there an implementation of the windows-1252 character
encoding in Emacs somewhere (one that would map iso-8859-1 characters
to iso-8859-1 characters, and all others to the corresponding Unicode
codepoints)? That would be useful in interacting with these annoying
systems that insist on pretending that windows-1252 "is" iso-8859-1.
Many thanks to those who can Enlighten me in this matter!
--
David A. Madore
(david.madore@ens.fr,
http://www.eleves.ens.fr:8080/home/madore/ )
next reply other threads:[~2003-05-10 15:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-10 15:21 David Madore [this message]
2003-05-10 17:06 ` getting out of raw-text encoding Kai Großjohann
2003-05-10 18:40 ` Eli Zaretskii
[not found] ` <mailman.5938.1052592339.21513.help-gnu-emacs@gnu.org>
2003-05-10 20:06 ` Kai Großjohann
2003-05-10 21:11 ` Eli Zaretskii
[not found] ` <mailman.5950.1052601438.21513.help-gnu-emacs@gnu.org>
2003-05-12 15:53 ` Kai Großjohann
2003-05-10 17:52 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='b9j5d4$rlf$1@nef.ens.fr' \
--to=david.madore@ens.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.