From: Eli Zaretskii Date: Sat, 15 Oct 2022 10:59:49 +0000 (+0300) Subject: Fix encoding and decoding of process I/O in Eshell on Windows X-Git-Tag: emacs-29.0.90~1616^2~612 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=63d084d4e435ae80e41ed19cfc48658819f84477;p=emacs.git Fix encoding and decoding of process I/O in Eshell on Windows * lisp/eshell/esh-proc.el (eshell-gather-process-output): Set up encoding and decoding of text to/from the subprocess for MS-Windows. (Bug#58281) --- diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index 7e005a0fc1c..bb928fc5fb0 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -277,7 +277,23 @@ Used only on systems which do not support async subprocesses.") eshell-delete-exited-processes delete-exited-processes)) (process-environment (eshell-environment-variables)) + (coding-system-for-read coding-system-for-read) + (coding-system-for-write coding-system-for-write) proc stderr-proc decoding encoding changed) + ;; MS-Windows needs special setting of encoding/decoding, because + ;; (a) non-ASCII text in command-line arguments needs to be + ;; encoded in the system's codepage; and (b) because many Windows + ;; programs will always interpret any non-ASCII input as encoded + ;; in the system codepage. + (when (eq system-type 'windows-nt) + (or coding-system-for-read ; Honor manual decoding settings + (setq coding-system-for-read + (coding-system-change-eol-conversion locale-coding-system + 'dos))) + (or coding-system-for-write ; Honor manual encoding settings + (setq coding-system-for-write + (coding-system-change-eol-conversion locale-coding-system + 'unix)))) (cond ((fboundp 'make-process) (unless (equal (car (aref eshell-current-handles eshell-output-handle)) @@ -325,7 +341,7 @@ Used only on systems which do not support async subprocesses.") (setq decoding (coding-system-change-eol-conversion decoding 'dos) changed t)) ;; Even if `make-process' left the coding system for encoding - ;; data sent from the process undecided, we had better use the + ;; data sent to the process undecided, we had better use the ;; same one as what we use for decoding. But, we should ;; suppress EOL conversion. (if (and decoding (not encoding))