( ?w . 48) ( ?x . 49) ( ?y . 50) ( ?z . 51) ( ?0 . 52) ( ?1 . 53)
( ?2 . 54) ( ?3 . 55) ( ?4 . 56) ( ?5 . 57) ( ?6 . 58) ( ?7 . 59)
( ?8 . 60) ( ?9 . 61) ( ?+ . 62) ( ?/ . 63)
- ))
+ ))
(defvar base64-alphabet-decoding-vector
(let ((v (make-vector 123 nil))
(setq p (cdr p)))
v))
+(defvar base64-binary-coding-system 'binary)
+
(defun base64-run-command-on-region (start end output-buffer command
&rest arg-list)
- (let ((tempfile nil) status errstring default-process-coding-system)
+ (let ((tempfile nil) status errstring default-process-coding-system
+ (coding-system-for-write base64-binary-coding-system)
+ (coding-system-for-read base64-binary-coding-system))
(unwind-protect
(progn
(setq tempfile (make-temp-name "base64"))
(setq errstring (buffer-string))
(kill-buffer nil)
(cons status errstring)))))
- (condition-case ()
- (delete-file tempfile)
- (error nil)))))
+ (ignore-errors
+ (delete-file tempfile)))))
(if (string-match "XEmacs" emacs-version)
(defalias 'base64-insert-char 'insert-char)
(if (or (null buffer) (eq buffer (current-buffer)))
(insert-char char count)
(with-current-buffer buffer
- (insert-char char count)))))
+ (insert-char char count))))
+ (setq base64-binary-coding-system 'no-conversion))
(defun base64-decode-region (start end)
(interactive "r")
(if base64-decoder-program
(let* ((binary-process-output t) ; any text already has CRLFs
(status (apply 'base64-run-command-on-region
- start end work-buffer
- base64-decoder-program
- base64-decoder-switches)))
+ start end work-buffer
+ base64-decoder-program
+ base64-decoder-switches)))
(if (not (eq status t))
(error "%s" (cdr status))))
(goto-char start)
(cond ((= counter 4)
(base64-insert-char (lsh bits -16) 1 nil work-buffer)
(base64-insert-char (logand (lsh bits -8) 255) 1 nil
- work-buffer)
+ work-buffer)
(base64-insert-char (logand bits 255) 1 nil
work-buffer)
(setq bits 0 counter 0))
(kill-buffer (current-buffer)))))
(fset 'base64-decode-string 'base64-decode)
+(fset 'base64-encode-string 'base64-encode)
(provide 'base64)