unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* getting out of raw-text encoding
@ 2003-05-10 15:21 David Madore
  2003-05-10 17:06 ` Kai Großjohann
  2003-05-10 17:52 ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: David Madore @ 2003-05-10 15:21 UTC (permalink / 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/ )

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-05-12 15:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-10 15:21 getting out of raw-text encoding David Madore
2003-05-10 17:06 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).