- (when (re-search-forward uu-begin-string nil t)
- (cond ((null file-name))
- ((stringp file-name))
- (t
- (setq file-name (expand-file-name
- (read-file-name "File to Name:"
- nil nil nil
- (match-string 1))))))
- (setq work-buffer (generate-new-buffer " *uudecode-work*"))
- (buffer-disable-undo work-buffer)
- (forward-line 1)
- (skip-chars-forward non-data-chars end)
- (while (not done)
- (setq inputpos (point))
- (setq remain 0 bits 0 counter 0)
- (cond
- ((> (skip-chars-forward uu-alphabet end) 0)
- (setq lim (point))
- (setq remain
- (logand (- (char-int (char-after inputpos)) 32) 63))
- (setq inputpos (1+ inputpos))
- (if (= remain 0) (setq done t))
- (while (and (< inputpos lim) (> remain 0))
- (setq bits (+ bits
- (logand
- (-
- (char-int (char-after inputpos)) 32) 63)))
- (if (/= counter 0) (setq remain (1- remain)))
- (setq counter (1+ counter)
- inputpos (1+ inputpos))
- (cond ((= counter 4)
- (uu-insert-char (lsh bits -16) 1 nil work-buffer)
- (uu-insert-char (logand (lsh bits -8) 255) 1 nil
- work-buffer)
- (uu-insert-char (logand bits 255) 1 nil
- work-buffer)
- (setq bits 0 counter 0))
- (t (setq bits (lsh bits 6)))))))
- (cond
- (done)
- ((> 0 remain)
- (error "uucode line ends unexpectly")
- (setq done t))
- ((and (= (point) end) (not done))
- (error "uucode ends unexpectly")
- (setq done t))
- ((= counter 3)
- (uu-insert-char (logand (lsh bits -16) 255) 1 nil
- work-buffer)
- (uu-insert-char (logand (lsh bits -8) 255) 1 nil
- work-buffer))
- ((= counter 2)
- (uu-insert-char (logand (lsh bits -10) 255) 1 nil
- work-buffer)))
- (skip-chars-forward non-data-chars end))
- (if file-name
- (save-excursion
- (set-buffer work-buffer)
- (write-file file-name))
- (or (markerp end) (setq end (set-marker (make-marker) end)))
- (goto-char start)
- (insert-buffer-substring work-buffer)
- (delete-region (point) end))))
- (and work-buffer (kill-buffer work-buffer)))))
+ (if enable-multibyte-characters
+ (dolist (x (nreverse result))
+ (insert (uudecode-string-to-multibyte x)))
+ (insert (apply 'concat (nreverse result))))
+ (delete-region (point) end))))))
+
+;;;###autoload
+(defun uudecode-decode-region (start end &optional file-name)
+ "Uudecode region between START and END.
+If FILE-NAME is non-nil, save the result to FILE-NAME."
+ (if uudecode-use-external
+ (uudecode-decode-region-external start end file-name)
+ (uudecode-decode-region-internal start end file-name)))