'quoted-printable-ccl-insert-encoded-file)
)
-(defun quoted-printable-ccl-decode-string (string)
- "Decode quoted-printable encoded STRING."
- (encode-coding-string
- string
- 'mel-ccl-quoted-printable-lf-lf-rev))
-
-(defun quoted-printable-ccl-decode-region (start end)
- "Decode the region from START to END with quoted-printable
+ (cond
+ ((eval-when-compile
+ (and (eq emacs-major-version 23)
+ (eq emacs-minor-version 1)))
+ (defun quoted-printable-ccl-decode-string (string)
+ "Decode quoted-printable encoded STRING."
+ (ccl-execute-on-string 'mel-ccl-decode-quoted-printable-lf-lf
+ (make-vector 9 0) string nil t))
+
+ (defun quoted-printable-ccl-decode-region (start end)
+ "Decode the region from START to END with quoted-printable
+encoding."
+ (interactive "*r")
+ (save-excursion
+ (goto-char start)
+ (insert (prog1 (quoted-printable-ccl-decode-string
+ (buffer-substring start end))
+ (delete-region start end)))))
+
+ (defun quoted-printable-ccl-write-decoded-region (start end filename)
+ "Decode quoted-printable encoded current region and write out to FILENAME."
+ (interactive "*r\nFWrite decoded region to file: ")
+ (let ((string (quoted-printable-ccl-decode-string
+ (buffer-substring start end)))
+ (coding-system-for-write 'binary)
+ jka-compr-compression-info-list jam-zcat-filename-list)
+ (with-temp-file filename
+ (insert string)))))
+ (t
+ (defun quoted-printable-ccl-decode-string (string)
+ "Decode quoted-printable encoded STRING."
+ (encode-coding-string
+ string
+ 'mel-ccl-quoted-printable-lf-lf-rev))
+
+ (defun quoted-printable-ccl-decode-region (start end)
+ "Decode the region from START to END with quoted-printable
encoding."
- (interactive "*r")
- (encode-coding-region start end 'mel-ccl-quoted-printable-lf-lf-rev))
-
-(defun quoted-printable-ccl-write-decoded-region (start end filename)
- "Decode quoted-printable encoded current region and write out to FILENAME."
- (interactive "*r\nFWrite decoded region to file: ")
- (let ((coding-system-for-write
- (if (coding-system-p 'mel-ccl-quoted-printable-lf-lf-rev-unix)
- 'mel-ccl-quoted-printable-lf-lf-rev-unix
- 'mel-ccl-quoted-printable-lf-lf-rev))
- jka-compr-compression-info-list jam-zcat-filename-list)
- (write-region start end filename)))
+ (interactive "*r")
+ (encode-coding-region start end 'mel-ccl-quoted-printable-lf-lf-rev))
+
+ (defun quoted-printable-ccl-write-decoded-region (start end filename)
+ "Decode quoted-printable encoded current region and write out to FILENAME."
+ (interactive "*r\nFWrite decoded region to file: ")
+ (let ((coding-system-for-write
+ (if (coding-system-p 'mel-ccl-quoted-printable-lf-lf-rev-unix)
+ 'mel-ccl-quoted-printable-lf-lf-rev-unix
+ 'mel-ccl-quoted-printable-lf-lf-rev))
+ jka-compr-compression-info-list jam-zcat-filename-list)
+ (write-region start end filename)))))
(mel-define-method-function
(mime-decode-string string (nil "quoted-printable"))
((eq mode 'text) 'mel-ccl-encode-uq)
((eq mode 'comment) 'mel-ccl-encode-cq)
(t 'mel-ccl-encode-pq))
- (make-vector 9 0) string nil t)))
+ (make-vector 9 0) string nil t))
+
+ (defun q-encoding-ccl-decode-string (string)
+ "Decode Q encoded STRING and return the result."
+ (ccl-execute-on-string 'mel-ccl-decode-q
+ (make-vector 9 0) string nil t)))
(t
(defun q-encoding-ccl-encode-string (string &optional mode)
"Encode STRING to Q-encoding of encoded-word, and return the result.
(cond
((eq mode 'text) 'mel-ccl-uq-rev)
((eq mode 'comment) 'mel-ccl-cq-rev)
- (t 'mel-ccl-pq-rev))))))
+ (t 'mel-ccl-pq-rev))))
-(defun q-encoding-ccl-decode-string (string)
- "Decode Q encoded STRING and return the result."
- (encode-coding-string
- string
- 'mel-ccl-uq-rev))
+ (defun q-encoding-ccl-decode-string (string)
+ "Decode Q encoded STRING and return the result."
+ (encode-coding-string
+ string
+ 'mel-ccl-uq-rev))))
(unless (featurep 'xemacs)
(defun q-encoding-ccl-encoded-length (string &optional mode)
((<= ?0 chr) (- chr ?0))
))
+(if (eval-when-compile
+ (> (string-to-char (string-as-multibyte "\200")) 128))
+ (defsubst quoted-printable-num-to-raw-byte-char (chr)
+ (if (and chr
+ (> chr 127))
+ (logior chr
+ (eval-when-compile
+ (- (string-to-char (string-as-multibyte "\200")) 128)))
+ chr))
+ (defsubst quoted-printable-num-to-raw-byte-char (chr)
+ chr))
+
(defun quoted-printable-internal-decode-region (start end)
(save-excursion
(save-restriction
;; encoded char.
(insert
(prog1
- (logior
- (ash (quoted-printable-hex-char-to-num (char-after (point))) 4)
- (quoted-printable-hex-char-to-num (char-after (1+ (point)))))
+ (quoted-printable-num-to-raw-byte-char
+ (logior
+ (ash (quoted-printable-hex-char-to-num (char-after (point))) 4)
+ (quoted-printable-hex-char-to-num (char-after (1+ (point))))))
(delete-region (1- (point))(+ 2 (point))))))
(t
;; invalid encoding.
"")
(h (setq l (quoted-printable-hex-char-to-num chr))
(prog1
- (char-to-string (logior (ash h 4) l))
+ (char-to-string
+ (quoted-printable-num-to-raw-byte-char
+ (logior (ash h 4) l)))
(setq h nil)))
(t (char-to-string chr)))))
string "")))