]> code.delx.au - gnu-emacs/commitdiff
Fix encoding of I/O in net-utils.el for MS-Windows. (Bug#19458)
authorEli Zaretskii <eliz@gnu.org>
Fri, 9 Jan 2015 09:50:21 +0000 (11:50 +0200)
committerEli Zaretskii <eliz@gnu.org>
Fri, 9 Jan 2015 09:50:21 +0000 (11:50 +0200)
 lisp/net/net-utils.el (net-utils-run-program, net-utils-run-simple):
 On MS-Windows, bind coding-system-for-read to the console output
 codepage.

lisp/ChangeLog
lisp/net/net-utils.el

index 2a6c960c4be65ff5d83c21f93ce68a4527aa7009..8481dd1fccecd57833d9a5bde73c4deeec2d44f8 100644 (file)
@@ -1,3 +1,9 @@
+2015-01-09  Eli Zaretskii  <eliz@gnu.org>
+
+       * net/net-utils.el (net-utils-run-program, net-utils-run-simple):
+       On MS-Windows, bind coding-system-for-read to the console output
+       codepage.  (Bug#19458)
+
 2015-01-08  Eli Zaretskii  <eliz@gnu.org>
 
        * simple.el (line-move-visual): When converting X pixel coordinate
index 28aa43117da3fcfd64f20b4e1c6384cd1319b917..ebcbc714ffb4631fac4df2a7f2cb470cfb208fac 100644 (file)
@@ -328,7 +328,15 @@ This variable is only used if the variable
 
 (defun net-utils-run-program (name header program args)
   "Run a network information program."
-  (let ((buf (get-buffer-create (concat "*" name "*"))))
+  (let ((buf (get-buffer-create (concat "*" name "*")))
+       (coding-system-for-read
+        ;; MS-Windows versions of network utilities output text
+        ;; encoded in the console (a.k.a. "OEM") codepage, which is
+        ;; different from the default system (a.k.a. "ANSI")
+        ;; codepage.
+        (if (eq system-type 'windows-nt)
+            (intern (format "cp%d" (w32-get-console-output-codepage)))
+          coding-system-for-read)))
     (set-buffer buf)
     (erase-buffer)
     (insert header "\n")
@@ -352,7 +360,15 @@ This variable is only used if the variable
       (when proc
         (set-process-filter proc nil)
         (delete-process proc)))
-    (let ((inhibit-read-only t))
+    (let ((inhibit-read-only t)
+       (coding-system-for-read
+        ;; MS-Windows versions of network utilities output text
+        ;; encoded in the console (a.k.a. "OEM") codepage, which is
+        ;; different from the default system (a.k.a. "ANSI")
+        ;; codepage.
+        (if (eq system-type 'windows-nt)
+            (intern (format "cp%d" (w32-get-console-output-codepage)))
+          coding-system-for-read)))
       (erase-buffer))
     (net-utils-mode)
     (setq-local net-utils--revert-cmd