unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: saufesma@gmail.com
Cc: 19458-done@debbugs.gnu.org
Subject: bug#19458: codepage
Date: Fri, 09 Jan 2015 11:53:17 +0200	[thread overview]
Message-ID: <83bnm85lgy.fsf@gnu.org> (raw)
In-Reply-To: <83fvbycq5t.fsf@gnu.org>

> Date: Mon, 29 Dec 2014 19:38:22 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: 19458@debbugs.gnu.org
> 
> > Date: Mon, 29 Dec 2014 21:31:06 +0400
> > From: igor denisov <saufesma@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@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@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
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





  reply	other threads:[~2015-01-09  9:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-28  9:04 bug#19458: codepage igor denisov
2014-12-28 18:01 ` Eli Zaretskii
2014-12-28 18:35   ` Eli Zaretskii
2014-12-28 18:37   ` Eli Zaretskii
     [not found]     ` <CAE0=M6oJDuvi_M3+nk_jvHs4f-5wkO_NGhdSLoeNLhFuL1P-=w@mail.gmail.com>
2014-12-29 16:02       ` Eli Zaretskii
     [not found]         ` <CAE0=M6qWnB-KwC6Kfdy1e3=tS9dgDm-yp0RVs+NwnVfJwbE2gA@mail.gmail.com>
2014-12-29 17:38           ` Eli Zaretskii
2015-01-09  9:53             ` Eli Zaretskii [this message]
     [not found]           ` <CAE0=M6rArTN62kT9Ko1egxSzPqrcAyoq6GG-+d-Ncy9igYCHYw@mail.gmail.com>
     [not found]             ` <83bnmmcpf4.fsf@gnu.org>
     [not found]               ` <CAE0=M6rUtZLJuyWNSswJ+YAOcHEW2Y3i8wGVbZm02yw-+zv2Lg@mail.gmail.com>
     [not found]                 ` <837fxacm6n.fsf@gnu.org>
     [not found]                   ` <CAE0=M6qX1CR=vsbuv4v3Grhfc3d5Mu8_2xWk1U6ssgrSeF33zA@mail.gmail.com>
     [not found]                     ` <834msecjyb.fsf@gnu.org>
     [not found]                       ` <CAE0=M6rqPt22QC_W5KPAMvavPMfMSSCjmLeRJnLwkccfVih-Aw@mail.gmail.com>
     [not found]                         ` <83y4pqb3s4.fsf@gnu.org>
     [not found]                           ` <CAE0=M6qMdOMa0kdqJ3ZnNUg_-BY=8Z_SPZWf+oZi1sG11V4+8g@mail.gmail.com>
2015-01-08  3:42                             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83bnm85lgy.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=19458-done@debbugs.gnu.org \
    --cc=saufesma@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).