From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Oliver Scholz Newsgroups: gmane.emacs.help Subject: Re: Encodings in Emacs. Date: Mon, 19 May 2003 11:57:31 +0200 Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1053339099 8469 80.91.224.249 (19 May 2003 10:11:39 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 19 May 2003 10:11:39 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Mon May 19 12:11:37 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19Hhc8-0002Bw-00 for ; Mon, 19 May 2003 12:11:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19HhRt-0005VY-01 for gnu-help-gnu-emacs@m.gmane.org; Mon, 19 May 2003 06:00:53 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-195-056.arcor-ip.NET!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 45 Original-NNTP-Posting-Host: dialin-145-254-195-056.arcor-ip.net (145.254.195.56) Original-X-Trace: fu-berlin.de 1053338323 28074414 145.254.195.56 (16 [87814]) X-Attribution: os X-Face: "HgH2sgK|bfH$; PiOJI6|qUCf.ve<51_Od(%ynHr?=>znn#~#oS>",F%B8&\vus),2AsPYb -n>PgddtGEn}s7kH?7kH{P_~vu?]OvVN^qD(L)>G^gDCl(U9n{:d>'DkilN!_K"eNzjrtI4Ya6;Td% IZGMbJ{lawG+'J>QXPZD&TwWU@^~A}f^zAb[Ru;CT(UA]c& User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3.50 (windows-nt) Cancel-Lock: sha1:91YMlmWXFguwgMy8sSJJOWCeQZ0= Original-Xref: shelby.stanford.edu gnu.emacs.help:113377 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:9871 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9871 Nacho writes: [...] > When I write text, I know how to change the encoding of the buffer to > save it with the encoding I want, for example, EUC-JP, ShiftJIS, etc. > > When I open it again, I have not to tell Emacs the encofing of the > file, he knows the encoding used. > > How can I know in what encoding is the file? On the left side of the modeline there is a small indicator that is meant to tell the file encoding of the current buffer. For example for UTF-8 its is "u", for Latin-1 it is "1". You could look at that. Or you could look at the value of the variable `buffer-file-coding-system' with `C-h v'. > Also, if I want to read a file in a specific encoding, how can I do > that? Or similarly, to change the encoding of a buffer but re-decofing > it. That is, if I change the encoding with M-x > set-buffer-file-coding-system it doesnt reencode the buffer. The use I > want to do to this is when I read a file with several codings mixed > (ShiftJIS and EUC-JP) and I want to read both. [...] When visiting a file, Emacs decodes that file into its internal encoding `emacs-mule'. Emacs encodes this internal format then again, when writing out the contents of the buffer. So when you do `C-x RET f' (`set-buffer-file-coding-system') you don't change the encoding of the buffer, you only tell Emacs to use another encoding when writing the contents of the buffer out. So the only way to get what you want is to tell Emacs which coding system it should use to read that file *before* Emacs visits it. You can do this with `C-x RET c'. For example: `C-x RET c shift_jis RET C-x f your-file.txt RET' But cautiion: I am not familiar with the encodings you mentioned, but I think when you have a file with several encodings you will break the parts with the "other" encodings, when you save that file. Oliver -- 30 Floréal an 211 de la Révolution Liberté, Egalité, Fraternité!