From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Anselm Helbig Newsgroups: gmane.emacs.help Subject: Re: switch between utf-8 and latin-1 (ARGH!!) Date: Sat, 18 Jul 2009 21:39:32 +0200 Organization: Freie Universitaet Berlin Message-ID: <87vdlpaih7.wl%anselm.helbig+news2009@googlemail.com> References: <1Sn8m.2418$vm5.686@tornado.fastwebnet.it> <87vdlpdg9l.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1247946048 11747 80.91.229.12 (18 Jul 2009 19:40:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 Jul 2009 19:40:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jul 18 21:40:41 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MSFlw-0007ry-2f for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Jul 2009 21:40:40 +0200 Original-Received: from localhost ([127.0.0.1]:42168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MSFlv-0001ls-K2 for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Jul 2009 15:40:39 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 38 Original-X-Trace: news.uni-berlin.de 4AG/P1A2DktBnXIajtLSWghCgO59ZqYDk0nKJAgf6hmQS9lQ2Ntb86Vedj Cancel-Lock: sha1:2icGLrGvBH1MaIadf1eqcSqnLA4= In-Reply-To: Mail-Followup-To: anselm.helbig+news2009@googlemail.com Original-Xref: news.stanford.edu gnu.emacs.help:171023 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:66207 Archived-At: At Sat, 18 Jul 2009 21:06:43 +0200, ?manu* 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