[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rmail and quoted-printable
From: |
Kaloian Doganov |
Subject: |
Re: rmail and quoted-printable |
Date: |
Tue, 05 Sep 2006 19:32:45 +0300 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Xavier Maillard <zedek@gnu.org> writes:
I can't find an elegant solution to deal with all these mails sent
with QP encoded body.
This doesn't qualify as 'elegant', but I've used this function, which
detects and handles both base64 and quoted-printable:
(defun mime-decode ()
(interactive)
(save-excursion
(re-search-forward "^--[^\n]+")
(beginning-of-line)
(let ((string (buffer-substring-no-properties
(point) (save-excursion (end-of-line)
(point))))
(buf (current-buffer))
start end meta-start)
(setq meta-start (point))
(search-forward "\n\n")
(setq start (point))
(search-forward string)
(beginning-of-line)
(setq end (point))
(let ((source-buffer (current-buffer))
(target-buffer (get-buffer-create "*foo*")))
(save-excursion
(set-buffer target-buffer)
(erase-buffer))
(append-to-buffer target-buffer start end)
(save-excursion
(goto-char meta-start)
(search-forward "\n\n" nil t)
(let ((mime-charset
(if (and rmail-decode-mime-charset
(save-excursion
(let ((case-fold-search
t))
(re-search-backward
rmail-mime-charset-pattern
meta-start t))))
(intern (downcase (match-string 1)))))
(mime-encoding
(save-excursion
(if (let ((case-fold-search t))
(re-search-backward
"^content-transfer-encoding:\\(\n?[\t ]\\)*\\([-a-z0-9]+\\)\\(\n?[\t ]\\)*"
meta-start t))
(intern (downcase (match-string 2)))
nil))))
(message "Detected charset: %s, encoding: %s"
mime-charset mime-encoding)
(save-excursion
(set-buffer target-buffer)
(cond ((string= mime-encoding "base64")
(base64-decode-region (point-min)
(point-max)))
((string= mime-encoding
"quoted-printable")
(quoted-printable-decode-region
(point-min) (point-max))))
(rmail-decode-region (point-min) (point-max)
mime-charset)
(goto-char (point-min))))
(switch-to-buffer target-buffer))))))
- Re: rmail and quoted-printable, (continued)
- Re: rmail and quoted-printable, Xavier Maillard, 2006/09/02
- Re: rmail and quoted-printable, Eli Zaretskii, 2006/09/02
- Re: rmail and quoted-printable, Xavier Maillard, 2006/09/02
- Re: rmail and quoted-printable, Eli Zaretskii, 2006/09/02
- Re: rmail and quoted-printable, Xavier Maillard, 2006/09/02
- Message not available
- Re: rmail and quoted-printable, Barry Margolin, 2006/09/02
- Re: rmail and quoted-printable, Xavier Maillard, 2006/09/03
- Re: rmail and quoted-printable, Jesper Harder, 2006/09/03
- Message not available
- Re: rmail and quoted-printable, Miles Bader, 2006/09/07
- Re: rmail and quoted-printable, Eli Zaretskii, 2006/09/07
Re: rmail and quoted-printable,
Kaloian Doganov <=