From: Augusto Stoffel <arstoffel@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 50560@debbugs.gnu.org
Subject: bug#50560: 28.0.50; 'insert-file-contents-literally' on multibyte buffers
Date: Mon, 13 Sep 2021 10:13:23 +0200 [thread overview]
Message-ID: <87wnnkvqos.fsf@gmail.com> (raw)
In-Reply-To: <875yv5j6gs.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 13 Sep 2021 09:10:59 +0200")
On Mon, 13 Sep 2021 at 09:10, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> Augusto Stoffel <arstoffel@gmail.com> 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.
next prev parent reply other threads:[~2021-09-13 8:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 6:58 bug#50560: 28.0.50; 'insert-file-contents-literally' on multibyte buffers Augusto Stoffel
2021-09-13 7:10 ` Lars Ingebrigtsen
2021-09-13 7:16 ` Lars Ingebrigtsen
2021-09-13 8:13 ` Augusto Stoffel [this message]
2021-09-13 8:19 ` Lars Ingebrigtsen
2021-09-13 8:42 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-13 12:05 ` Eli Zaretskii
2021-09-13 13:18 ` Lars Ingebrigtsen
2021-09-13 21:37 ` Augusto Stoffel
2021-09-13 11:52 ` Eli Zaretskii
2021-09-13 12:44 ` Augusto Stoffel
2021-09-13 13:26 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wnnkvqos.fsf@gmail.com \
--to=arstoffel@gmail.com \
--cc=50560@debbugs.gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.