help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: switch between utf-8 and latin-1 (ARGH!!)


From: Anselm Helbig
Subject: Re: switch between utf-8 and latin-1 (ARGH!!)
Date: Sat, 18 Jul 2009 21:39:32 +0200

At Sat, 18 Jul 2009 21:06:43 +0200,
?manu* <paolNOini@math.SPAMunifi.it> wrote:
> 
> Thank you so much. I have spent maybe one or two hours to understand 
> what was happening to my buffers. I tell you because it's a little bit 
> funny.
> 
> I open my buffer with UTF-8 encoding, and i see all the multibyte 
> characters scrambled. Then I insert the line -*- coding:utf-8 -*- at the 
> beginning and I save the buffer. Then I exit emacs and reopen the 
> buffer. Apparently nothing has changed.
> 
> What was happening was that after I write that line on the buffer, when 
> I save the buffer emacs converted the utf-8 escape characters in utf-8 
> (this seems a wrong behaviour to me!). Looking with hexdump I can see 
> that the original two bytes characters become four bytes.
> 
> The only solution I found was to use another editor to insert that 
> line!!! This is awkward!

You don't need another editor to do that. Just try to understand what
emacs is doing here: when you added the line about the coding system
emacs understood that you want the contents of the buffer saved with
this coding system. Emacs can not know that the characters on screen
are not what you want! So you first have to get to the point where
Emacs has the correct notion about the coding system. Pascal already
pointed you to `set-buffer-file-coding-system', another way is to use
`universal-coding-system-argument' (C-x RET c) immediately before
opening a file.

HTH, 

Anselm


-- 
Anselm Helbig 
mailto:anselm.helbig+news2009@googlemail.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]