From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: [HELP] (bug?) Saving a buffer without any conversion? Date: 14 Jan 2003 02:00:05 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <5xk7h8a6lm.fsf@kfs2.cua.dk> References: <87fzrxszs8.fsf@lexx.delysid.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1042502549 14890 80.91.224.249 (14 Jan 2003 00:02:29 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 14 Jan 2003 00:02:29 +0000 (UTC) Cc: Mario Lang Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18YEXB-0003ri-00 for ; Tue, 14 Jan 2003 01:02:25 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18YEet-0006TP-00 for ; Tue, 14 Jan 2003 01:10:23 +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 18YEWV-0003n9-06 for emacs-devel@quimby.gnus.org; Mon, 13 Jan 2003 19:01:43 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18YEW6-0003iz-00 for emacs-devel@gnu.org; Mon, 13 Jan 2003 19:01:18 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18YEW4-0003gS-00 for emacs-devel@gnu.org; Mon, 13 Jan 2003 19:01:17 -0500 Original-Received: from mail.filanet.dk ([195.215.206.179]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18YEVU-0003Ji-00 for emacs-devel@gnu.org; Mon, 13 Jan 2003 19:00:41 -0500 Original-Received: from kfs2.cua.dk.cua.dk (unknown [10.1.82.3]) by mail.filanet.dk (Postfix) with SMTP id D2F237C012; Tue, 14 Jan 2003 01:00:39 +0100 (CET) Original-To: emacs-devel@gnu.org In-Reply-To: <87fzrxszs8.fsf@lexx.delysid.org> Original-Lines: 47 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 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:10714 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10714 Mario Lang writes: > Hi there. > > I'm trying to sort out a bug in erc-dcc.el since some time now and since > I'm really lost now, I thought I'd ask here, and maybe get some enlightenment: > > We're receiving binary content via a network process. After the > transfer is complete, this buffer should be saved to a file. > > The effect I'm having is that we receive 1372422 bytes via the process > filter function STRING argument, and after insertion into a buffer, > we have a buffer with buffer-size 1372422, but after calling (save-buffer) > we get this: > > -rw-r--r-- 1 root root 1865264 Jan 13 18:35 blah28.mp3 > > I'm using: > > (set-process-coding-system proc 'binary 'binary) > (set-buffer-file-coding-system 'no-conversion t) > I have looked at Mario's data before sending it to emacs and after emacs has written it to a file. It seems that every byte in the range 0xa0 .. 0xff that were in the original file is prefixed with an 0x81 byte in the file containing the received data. To me, that looks like the internal multi-byte representation for the binary data. Actually the value returned by (buffer-size) in the buffer containing the received binary data equals the size of the original data (so if seen from the lisp level, the buffer contains the right number of bytes). But when written to disk, the internal representation of the buffer is stored instead of the "data". The buffer's coding system for save is no-conversion. How did that internal data end up in the file? What coding systems should be set on the network process and on the buffer to make it possible to have the received binary data in the buffer make its way unmangled into the file on the disk? -- Kim F. Storm http://www.cua.dk