Gnus development mailing list
 help / color / mirror / Atom feed
* How to use base64-encode-region with MULE?
@ 1999-05-05 11:54 Kai.Grossjohann
  1999-06-12 22:48 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Kai.Grossjohann @ 1999-05-05 11:54 UTC (permalink / raw)


Currently, I use write-region to save stuff to a tmp file, then
execute mimencode on the tmp file.  I assume that write-region does
some MULE magic if the region contains non-ASCII things.

I would like to do away with the tmp file and call
base64-encode-region instead.  But how to deal with the MULE magic in
this case?

As base64.el is part of Gnus, I thought this would be the right place
to ask...

tia,
kai
-- 
Abort this operation?   [Abort]  [Cancel]


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use base64-encode-region with MULE?
  1999-05-05 11:54 How to use base64-encode-region with MULE? Kai.Grossjohann
@ 1999-06-12 22:48 ` Lars Magne Ingebrigtsen
  1999-06-12 23:29   ` Hrvoje Niksic
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 1999-06-12 22:48 UTC (permalink / raw)


Kai.Grossjohann@CS.Uni-Dortmund.DE writes:

> I would like to do away with the tmp file and call
> base64-encode-region instead.  But how to deal with the MULE magic in
> this case?

You have to de-Mulify the buffer before calling base64-encode-region.
And, in Emacs 20.3 you have to be in a unibyte buffer.

So you basically would do something like

(encode-coding-region (point-min) (point-max) 'iso-8859-1) ; or something
(setq r (buffer-string))
(mm-with-unibyte-buffer
  (insert t)
  (base64-encode-region (point-min) (point-max))
  (setq base64 (buffer-string)))

Presto!  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use base64-encode-region with MULE?
  1999-06-12 22:48 ` Lars Magne Ingebrigtsen
@ 1999-06-12 23:29   ` Hrvoje Niksic
  1999-06-12 23:57     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Hrvoje Niksic @ 1999-06-12 23:29 UTC (permalink / raw)


Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> And, in Emacs 20.3 you have to be in a unibyte buffer.

Why?  Isn't it sufficient that all the characters are within [0,255]
range?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use base64-encode-region with MULE?
  1999-06-12 23:29   ` Hrvoje Niksic
@ 1999-06-12 23:57     ` Lars Magne Ingebrigtsen
  1999-06-13  0:16       ` Hrvoje Niksic
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 1999-06-12 23:57 UTC (permalink / raw)


Hrvoje Niksic <hniksic@srce.hr> writes:

> > And, in Emacs 20.3 you have to be in a unibyte buffer.
> 
> Why?  Isn't it sufficient that all the characters are within [0,255]
> range?

No -- é, for instance, is encoded internally as \201\040 (or
something).  Well, after you've encoded, it's no longer an é, but
there's still no actual character > 0x80 in the buffer.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use base64-encode-region with MULE?
  1999-06-12 23:57     ` Lars Magne Ingebrigtsen
@ 1999-06-13  0:16       ` Hrvoje Niksic
  1999-06-13  1:43         ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Hrvoje Niksic @ 1999-06-13  0:16 UTC (permalink / raw)


Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Hrvoje Niksic <hniksic@srce.hr> writes:
> 
> > > And, in Emacs 20.3 you have to be in a unibyte buffer.
> > 
> > Why?  Isn't it sufficient that all the characters are within [0,255]
> > range?
> 
> No -- é, for instance, is encoded internally as \201\040 (or
> something).

Well yes, but shouldn't the Base64 code proceed character by character
and read the "decoded" characters from the buffer?  That's what the
code in XEmacs does, and to me it seems like the only sensible thing
to do.  Otherwise, you get the \201 junk in otherwise perfectly fine
buffers.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use base64-encode-region with MULE?
  1999-06-13  0:16       ` Hrvoje Niksic
@ 1999-06-13  1:43         ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 1999-06-13  1:43 UTC (permalink / raw)


Hrvoje Niksic <hniksic@srce.hr> writes:

> Well yes, but shouldn't the Base64 code proceed character by character
> and read the "decoded" characters from the buffer?  That's what the
> code in XEmacs does, and to me it seems like the only sensible thing
> to do.  Otherwise, you get the \201 junk in otherwise perfectly fine
> buffers.

Yup.  The Emacs implementation encodes the internal representation.
One the one hand, that may seem totally weird.  On the other hand,
Emacs has both multibyte and unibyte buffers, so this isn't all that
catastrophic for Emacs, while doing the same in XEmacs would be, er,
catastrophic.  

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-06-13  1:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-05 11:54 How to use base64-encode-region with MULE? Kai.Grossjohann
1999-06-12 22:48 ` Lars Magne Ingebrigtsen
1999-06-12 23:29   ` Hrvoje Niksic
1999-06-12 23:57     ` Lars Magne Ingebrigtsen
1999-06-13  0:16       ` Hrvoje Niksic
1999-06-13  1:43         ` Lars Magne Ingebrigtsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).