jwiegley / emacs-async

Simple library for asynchronous processing in Emacs
GNU General Public License v3.0
838 stars 68 forks source link

Error when processing non-latin characters #7

Closed sabof closed 11 years ago

sabof commented 12 years ago

Whenever I try moving a file with utf8 characters, I get (error "Multibyte character in data for base64 encoding") from async--insert-sexp

I haven't tested it extensively, but this seems to work:

(defun async--insert-sexp (sexp)
  (prin1 sexp (current-buffer))
  ;; Just in case the string we're sending might contain EOF
  (encode-coding-region (point-min) (point-max) 'utf-8-unix)
  (base64-encode-region (point-min) (point-max) t)
  (goto-char (point-min)) (insert ?\")
  (goto-char (point-max)) (insert ?\" ?\n))

(defun async--receive-sexp (&optional stream)
  (let ((sexp (decode-coding-string (base64-decode-string (read stream)) 'utf-8-unix)))
    (if async-debug
        (message "Received sexp {{{%s}}}" (pp-to-string sexp)))
    (setq sexp (read sexp))
    (if async-debug
        (message "Read sexp {{{%s}}}" (pp-to-string sexp)))
    (eval sexp)))
jwiegley commented 12 years ago

Are you using dired-async to do the copy?

sabof commented 12 years ago

Yes, you should get the error if you copy/move a file with dired

myuhe commented 11 years ago

I have same problem , and sabof's patch works correctly. Please merge this patch.

thierryvolpiatto commented 11 years ago

I have merged this change, please make a pull request next time, thanks. @jwiegley Can you have a look at this and try it?

myuhe commented 11 years ago

@thierryvolpiatto Thanks!!