;;; mel-q.el: Quoted-Printable and Q-encoding encoder/decoder for GNU Emacs
-;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
+;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
;; Created: 1995/6/25
-;; Version: $Id: mel-q.el,v 7.1 1997/11/06 16:09:25 morioka Exp $
;; Keywords: MIME, Quoted-Printable, Q-encoding
;; This file is part of MEL (MIME Encoding Library).
;;; Code:
(require 'emu)
+(require 'mime-def)
;;; @ Quoted-Printable encoder
;;;
-(defconst quoted-printable-hex-chars "0123456789ABCDEF")
-
(defsubst quoted-printable-quote-char (character)
(concat
"="
(save-restriction
(narrow-to-region start end)
(goto-char start)
- (let ((col 0)
- enable-multibyte-characters)
+ (let ((col 0))
(while (< (point)(point-max))
(cond ((>= col 75)
(insert "=\n")
(setq col 0)
)
- ((looking-at "^From ")
+ ((looking-at-as-unibyte "^From ")
(replace-match "=46rom ")
(backward-char 1)
(setq col (+ col 6))
)
- ((looking-at "[ \t]\n")
+ ((looking-at-as-unibyte "[ \t]\n")
(forward-char 1)
(insert "=\n")
(forward-char 1)
)))
)))))
+
(defvar quoted-printable-external-encoder '("mmencode" "-q")
"*list of quoted-printable encoder program name and its arguments.")
)
)))
+
(defvar quoted-printable-internal-encoding-limit
(if (and (featurep 'xemacs)(featurep 'mule))
0
(quoted-printable-internal-encode-region start end)
))
+
(defun quoted-printable-encode-string (string)
"Encode STRING to quoted-printable, and return the result."
(with-temp-buffer
(buffer-string)
))
+
(defun quoted-printable-insert-encoded-file (filename)
"Encode contents of file FILENAME to quoted-printable, and insert the result.
It calls external quoted-printable encoder specified by
)))
string "")))
-(defconst quoted-printable-octet-regexp
- (concat "=[" quoted-printable-hex-chars
- "][" quoted-printable-hex-chars "]"))
-
(defun quoted-printable-internal-decode-region (start end)
(save-excursion
(save-restriction
(setq e (match-end 0))
(setq str (buffer-substring b e))
(delete-region b e)
- (insert (quoted-printable-decode-string str))
+ (insert (string-as-multibyte (quoted-printable-decode-string str)))
))
)))
+
(defvar quoted-printable-external-decoder '("mmencode" "-q" "-u")
"*list of quoted-printable decoder program name and its arguments.")
t t nil (cdr quoted-printable-external-decoder))
)))
+
(defvar quoted-printable-internal-decoding-limit nil
"*limit size to use internal quoted-printable decoder.
If size of input to decode is larger than this limit,
(quoted-printable-internal-decode-region start end)
))
+
+(defvar quoted-printable-external-decoder-option-to-specify-file '("-o")
+ "*list of options of quoted-printable decoder program to specify file.")
+
+(defun quoted-printable-write-decoded-region (start end filename)
+ "Decode and write current region encoded by quoted-printable into FILENAME.
+START and END are buffer positions."
+ (interactive
+ (list (region-beginning) (region-end)
+ (read-file-name "Write decoded region to file: ")))
+ (as-binary-process
+ (apply (function call-process-region)
+ start end (car quoted-printable-external-decoder)
+ nil nil nil
+ (append (cdr quoted-printable-external-decoder)
+ quoted-printable-external-decoder-option-to-specify-file
+ (list filename))
+ )))
+
\f
;;; @ Q-encoding encode/decode string
;;;