-
-;;; @@ Quoted-Printable encoder/decoder for file
-;;;
-
-(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
-`quoted-printable-external-encoder'. So you must install the program
-(maybe mmencode included in metamail or XEmacs package)."
- (interactive (list (read-file-name "Insert encoded file: ")))
- (apply (function call-process) (car quoted-printable-external-encoder)
- filename t nil (cdr quoted-printable-external-encoder))
- )
+(defun quoted-printable-decode-string (string)
+ "Decode STRING which is encoded in quoted-printable, and return the result."
+ (with-temp-buffer
+ (insert string)
+ (quoted-printable-decode-region (point-min)(point-max))
+ (buffer-string)))
+
+
+(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))
+ )))