GNU bug report logs - #19458
codepage

Previous Next

Package: emacs;

Reported by: igor denisov <saufesma <at> gmail.com>

Date: Sun, 28 Dec 2014 17:41:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #28 received at 19458-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: saufesma <at> gmail.com
Cc: 19458-done <at> debbugs.gnu.org
Subject: Re: bug#19458: codepage
Date: Fri, 09 Jan 2015 11:53:17 +0200
> Date: Mon, 29 Dec 2014 19:38:22 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 19458 <at> debbugs.gnu.org
> 
> > Date: Mon, 29 Dec 2014 21:31:06 +0400
> > From: igor denisov <saufesma <at> gmail.com>
> > 
> > This works perfectly
> > 
> > M-: (let ((coding-system-for-read 'cp866)) (netstat)) RET
> 
> OK, thanks.  Now I know how to fix the command.

OK, I fixed it now (commit 1f179ea on the emacs-24 branch).  The patch
appears below, if you want to start using it right away.

commit 1f179ea1bac65d911c616dafbf7147f0dbb39afd
Author: Eli Zaretskii <eliz <at> gnu.org>
Date:   Fri Jan 9 11:50:21 2015 +0200

    Fix encoding of I/O in net-utils.el for MS-Windows.  (Bug#19458)
    
     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.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2a6c960..8481dd1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2015-01-09  Eli Zaretskii  <eliz <at> 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 <at> gnu.org>
 
 	* simple.el (line-move-visual): When converting X pixel coordinate
diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index 28aa431..ebcbc71 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -328,7 +328,15 @@ (defun net-utils-remove-ctrl-m-filter (process output-string)
 
 (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 @@ (defun net-utils-run-simple (buffer program-name args &optional nodisplay)
       (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




This bug report was last modified 10 years and 134 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.