(epa-display-info (epg-verify-result-to-string
(epg-context-result-for context 'verify)))))))
+(defun epa--find-coding-system-for-mime-charset (mime-charset)
+ (if (featurep 'xemacs)
+ (if (fboundp 'find-coding-system)
+ (find-coding-system mime-charset))
+ (let ((pointer (coding-system-list)))
+ (while (and pointer
+ (eq (coding-system-get (car pointer) 'mime-charset)
+ mime-charset))
+ (setq pointer (cdr pointer)))
+ pointer)))
+
;;;###autoload
(defun epa-decrypt-armor-in-region (start end)
"Decrypt OpenPGP armors in the current region between START and END.
(save-restriction
(narrow-to-region start end)
(goto-char start)
- (let (armor-start armor-end charset coding-system)
+ (let (armor-start armor-end coding-system)
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
(setq armor-start (match-beginning 0)
armor-end (re-search-forward "^-----END PGP MESSAGE-----$"
(error "No armor tail"))
(goto-char armor-start)
(if (re-search-forward "^Charset: \\(.*\\)" armor-end t)
- (setq charset (match-string 1)))
- (if coding-system-for-read
- (setq coding-system coding-system-for-read)
- (if charset
- (setq coding-system (intern (downcase charset)))
- (setq coding-system 'utf-8)))
- (let ((coding-system-for-read coding-system))
+ (setq coding-system (epa--find-coding-system-for-mime-charset
+ (intern (downcase (match-string 1))))))
+ (let ((coding-system-for-read
+ (or coding-system-for-read
+ coding-system)))
(epa-decrypt-region armor-start armor-end)))))))
;;;###autoload