From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: [HELP] (bug?) Saving a buffer without any conversion? Date: Wed, 15 Jan 2003 19:59:04 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200301151059.TAA09873@etlken.m17n.org> References: <87fzrxszs8.fsf@lexx.delysid.org> <200301150116.KAA09223@etlken.m17n.org> <5xk7h67k1b.fsf@kfs2.cua.dk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: main.gmane.org 1042628387 21015 80.91.224.249 (15 Jan 2003 10:59:47 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 15 Jan 2003 10:59:47 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18YlGq-0005Sj-00 for ; Wed, 15 Jan 2003 11:59:44 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18YlPF-0001Pe-00 for ; Wed, 15 Jan 2003 12:08:25 +0100 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 18YlGy-0006dt-09 for emacs-devel@quimby.gnus.org; Wed, 15 Jan 2003 05:59:52 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18YlGm-0006Pz-00 for emacs-devel@gnu.org; Wed, 15 Jan 2003 05:59:40 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18YlGW-0005pB-00 for emacs-devel@gnu.org; Wed, 15 Jan 2003 05:59:24 -0500 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18YlGJ-0005Eh-00 for emacs-devel@gnu.org; Wed, 15 Jan 2003 05:59:12 -0500 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])h0FAx4k07867; Wed, 15 Jan 2003 19:59:04 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) h0FAx4R06491; Wed, 15 Jan 2003 19:59:04 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id TAA09873; Wed, 15 Jan 2003 19:59:04 +0900 (JST) Original-To: storm@cua.dk In-reply-to: <5xk7h67k1b.fsf@kfs2.cua.dk> (storm@cua.dk) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) Original-cc: mlang@delysid.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10744 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10744 In article <5xk7h67k1b.fsf@kfs2.cua.dk>, storm@cua.dk (Kim F. Storm) writes: > He uses a process filter to "insert" the received strings to the > buffer like this [approximately]: > (defun filter (proc string) > (with-current-buffer (process-buffer proc) > (insert string))) Ah! Now I see what's going on. If the coding system for proc is no-conversion or raw-text, STRING above is unibyte, thus, when inserted in a multibyte buffer, it is converted to the corresponding multibyte string. This conversion converts all 0xA0..0xFF to Latin-1 (in Latin-1 lang. env.). > Here is a small, selfcontained test case. > If you eval the following form, wait a few seconds, the result is > "BUFFER=10 FILE=20" > meaning that the temp.out buffer is 10 "bytes", but the written > file is 20 "bytes". > Adding the "set-buffer-multibyte" line produces the right result. Yes. And, instead of adding that, chaging this: > :filter (lambda (proc string) > (with-current-buffer (get-buffer "temp.out") > (insert string))) to this: > :filter (lambda (proc string) > (with-current-buffer (get-buffer "temp.out") > (insert (string-as-multibyte string)))) also produces the right result. Which is the better solution? It depends on how the buffer is used later. If it is just to save the received bytes in a file, using a unibyte buffer is better. But, in that case, first of all, why is the process filter necessary? --- Ken'ichi HANDA handa@m17n.org