From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#50560: 28.0.50; 'insert-file-contents-literally' on multibyte buffers Date: Mon, 13 Sep 2021 10:13:23 +0200 Message-ID: <87wnnkvqos.fsf@gmail.com> References: <87zgshotc1.fsf@gmail.com> <875yv5j6gs.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5726"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 50560@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 13 10:14:27 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mPh6f-0001GQ-E6 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Sep 2021 10:14:25 +0200 Original-Received: from localhost ([::1]:46716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPh6e-0003SW-Dh for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Sep 2021 04:14:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPh6T-0003SD-Ca for bug-gnu-emacs@gnu.org; Mon, 13 Sep 2021 04:14:14 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPh6I-0000aT-HO for bug-gnu-emacs@gnu.org; Mon, 13 Sep 2021 04:14:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mPh6I-0003Oz-Cf for bug-gnu-emacs@gnu.org; Mon, 13 Sep 2021 04:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Sep 2021 08:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50560 X-GNU-PR-Package: emacs Original-Received: via spool by 50560-submit@debbugs.gnu.org id=B50560.163152081513019 (code B ref 50560); Mon, 13 Sep 2021 08:14:02 +0000 Original-Received: (at 50560) by debbugs.gnu.org; 13 Sep 2021 08:13:35 +0000 Original-Received: from localhost ([127.0.0.1]:44196 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mPh5r-0003Nv-EP for submit@debbugs.gnu.org; Mon, 13 Sep 2021 04:13:35 -0400 Original-Received: from mail-wr1-f47.google.com ([209.85.221.47]:37780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mPh5n-0003Ne-SI for 50560@debbugs.gnu.org; Mon, 13 Sep 2021 04:13:34 -0400 Original-Received: by mail-wr1-f47.google.com with SMTP id t8so8206940wrq.4 for <50560@debbugs.gnu.org>; Mon, 13 Sep 2021 01:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ADkW9C8L9Ltlk7qtgGG+XjIylxI0byR4ZUXtghlE3SI=; b=LFuvu9KSKm5AM1Xj7vHrtJqtHprru6SIqjPbhKCiXaaw3rR1WSzxcN9/1q1EPmoDZz pt0uyz3dz5jv2xlMVz8LBx2VZmYHPju5eBgjVMpSwWpuBX0mx0a1cfzaIF26l3O76df+ NXkJwMvfNIoCkZUYs/ZNwcmbtU8eQbqzRBS3DMk8rKKRyNSwk6CfCvHkY3oFQnJEvp1v FrSsuOzsEES/LLU2YdOZfBHvfP5BwYbFYRCvU84zFvmEjdbUWH0zjGVxlQNUKZFT1nh5 GMBIwtbsyEu8JQ7EMJ28Uc8p4EZSnzGcL3ji0IZh/N/ybhBCuBe0d6vbdjGl9hbifDdL kf5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=ADkW9C8L9Ltlk7qtgGG+XjIylxI0byR4ZUXtghlE3SI=; b=vBaEVxW0Tl6ZTjhMy0PHCBYAIyow0wPyzHDfQpRF80reZONQgVWos490RDZ4SJpS+W GNE9dou69ICTf3purfEnza35cHU044/0MtriK8wMANV42qyZ62rs1/I/2qNUOg+pzsCY TwV6nnCyQIze4kko/RhB54mVd2dnYIKaxpdTfo3ZyGUaY3NAuHbE5TnTvKXnmnDe8l30 nCVTAfBGFhwxm6gVuemXJBnhm0okHBwY7gIV+BlMkMlKdonK+XYIeoQvmho/0id1DsHz Fgro9rSudXv9rTglN6pX5poivq1pHecyCkLOB7aBWnWrwjtfFMsjyyqnHziO4I0y4SUX OSOA== X-Gm-Message-State: AOAM530L2Owmve59AoEqf3yKY23caUDqhAo0f9NVUu3EyjJqbTKAxfjx wYLKLAGzloLcQmVYGlFMJFdfJXu7EQg= X-Google-Smtp-Source: ABdhPJy+YszGzrCqndeTd6LLFL1nSVhgcIKRmsEvDOuiXEMKK9pGZCu63Cwn+8dSE29Ej+YKWSCCvQ== X-Received: by 2002:adf:b7c7:: with SMTP id t7mr10652176wre.259.1631520805772; Mon, 13 Sep 2021 01:13:25 -0700 (PDT) Original-Received: from ars3 (pd95c95b0.dip0.t-ipconnect.de. [217.92.149.176]) by smtp.gmail.com with ESMTPSA id u6sm8127879wrp.0.2021.09.13.01.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 01:13:25 -0700 (PDT) In-Reply-To: <875yv5j6gs.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 13 Sep 2021 09:10:59 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214193 Archived-At: On Mon, 13 Sep 2021 at 09:10, Lars Ingebrigtsen wrote: > Augusto Stoffel writes: > >> I thought 'insert-file-contents-literally' literally just inserted the >> file contents, as bytes, but I noticed that in the following code >> >> (create-image >> (with-temp-buffer >> (set-buffer-multibyte nil) >> (insert-file-contents-literally "picure.jpg") >> (buffer-substring-no-properties (point-min) (point-max))) >> nil t) >> >> the call to 'set-buffer-multibyte' is really essential. > > In what way? If the first byte in a binary file is #xff, inserting the > file literally in a buffer and saying `(following-char)' on the first > character in the buffer will say #xff. > > But, yes, when dealing with octet streams, it's a lot less confusing if > you're using unibyte buffers (and strings). > >> Is this intended? If so, I think a note in the doctring is due. > > The doc string doesn't say anything about bytes, so I think that's an > interpretation on your side. > > `insert-file-contents-literally' does insert "literally" -- but the byte > contents of the internal buffer structure can't be violated (emacs uses > utf-8 (plus extensions) for multibyte buffers). Ah, sure, there is no coding _conversion_, but the bytes are still interpreted according to the buffer's coding system. I guess that's obvious in hindsight. Still, reading the bytes from a file is slightly trickier than it might seem, so there could be a word of caution somewhere.