all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@is.elta.co.il>
Cc: bug-gnu-emacs@gnu.org
Subject: Re: base64-decode-region inserts carriage-returns
Date: Sun, 9 Jun 2002 12:13:45 +0300 (IDT)	[thread overview]
Message-ID: <Pine.SUN.3.91.1020609120453.14991A-100000@is> (raw)
In-Reply-To: <87u1od7b99.fsf@blarg.net>


On 8 Jun 2002, Eric Hanchrow wrote:

> Save the decoded version to a different file for comparison with the
> original:
> 
>         C-x C-w bin.again RET
> 
> Now examine the newly-saved version with od back at the shell:
> 
>         od -c /tmp/bin.again 
> 
>         you'll now see 0000000 001 002 003  \r  \n 001 002 003  \r  \n
> 
> Thus the binary file has had some carriage-returns inserted into it,

This happens because the buffer where you performed the conversion has 
undecided-dos as the value of its buffer-file-coding-system variable.

> which is a Bad Thing, since those carriage-returns were not present in
> the encoded data.

I'm not sure your conclusion is right.  base64-decode-region is a 
primitive which acts on a region.  It doesn't have any clue about what 
does the caller want to do with the result of decoding, and it is IMHO 
wrong to change buffer-file-coding-system because something you did with 
a portion of buffer's text.

For example, imagine that some program source sent as a base64-encoded 
attachment is being decoded on a Windows system.  In that case, I think 
there's nothing wrong with saving the result with DOS EOLs; users might 
even expect that.

More generally, the way the buffer should be saved is something a user or 
higher-level features should determine.  That is, it is up to the caller 
of base64-decode-region to decide whether or not to change the way buffer 
is encoded when written  Primitives that operate on a region should not 
change that.

I'd say that a user-friendly interface to base64-decode-region should 
decode the text in a scratch buffer, and the insert the result into the 
user buffer.  That way, the value of buffer-file-coding-system in the 
scratch buffer doesn't count, and encoding of the user buffer is not 
affected by a primitive.

  parent reply	other threads:[~2002-06-09  9:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-08 20:42 base64-decode-region inserts carriage-returns Eric Hanchrow
2002-06-08 21:06 ` Eric Hanchrow
2002-06-09  9:13 ` Eli Zaretskii [this message]
2002-06-10 10:14 ` Richard Stallman

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=Pine.SUN.3.91.1020609120453.14991A-100000@is \
    --to=eliz@is.elta.co.il \
    --cc=bug-gnu-emacs@gnu.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.