emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 8f03888: * lisp/gnus/gnus-art.el: Fix up compiler warnings.


From: Eli Zaretskii
Subject: Re: master 8f03888: * lisp/gnus/gnus-art.el: Fix up compiler warnings.
Date: Fri, 16 Jan 2015 10:54:31 +0200

> From: Lars Magne Ingebrigtsen <address@hidden>
> Date: Fri, 16 Jan 2015 03:22:45 +0100
> Cc: address@hidden
> 
> (defun utf7-fragment-encode (start end &optional for-imap)
>   "Encode text from START to END in buffer as UTF-7 escape fragment.
> Use IMAP modification if FOR-IMAP is non-nil."
>   (save-restriction
>     (narrow-to-region start end)
>     (funcall (utf7-get-u16char-converter 'to-utf-16))
>     (mm-with-unibyte-current-buffer
>       (base64-encode-region start (point-max)))
>     (goto-char start)
>     (let ((pm (point-max)))
>       (when for-imap
>       (while (search-forward "/" nil t)
>         (replace-match ",")))
>       (skip-chars-forward "^= \t\n" pm)
>       (delete-region (point) pm))))
> 
> So we have some non-ASCII text in the buffer, and er, we convert that to
> utf-16?  And then we convert the utf-16 represented as utf-8 byte
> sequences to base64?  Uhm.

The UTF-16 encoded text is represented as series of 8-bit bytes, which
are themselves represented as UTF-8 sequences outside of the Unicode
range of characters.  There's no special problem here, since Emacs is
quite capable of holding raw bytes in a multibyte buffer.

> Yeah, OK, `mm-with-unibyte-current-buffer' is probably not helping with
> understanding that function any.  :-)  So if somebody would be so kind
> to rewrite these functions, that would be nice.

I would suggest using the optional DESTINATION argument of
encode-coding-region, pointing it at a separate scratch buffer that
was made unibyte when it was created.  Thgen base64-encode-region
could be run on that buffer without the mm-with-unibyte-current-buffer
stuff.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]