unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: MS Windows: utf-8 in command line
Date: Thu, 23 Jun 2016 18:21:50 +0300	[thread overview]
Message-ID: <83oa6s2anl.fsf@gnu.org> (raw)
In-Reply-To: <87k2hghc4g.fsf@wanadoo.es> (message from Óscar Fuentes on Thu, 23 Jun 2016 04:28:47 +0200)

> From: Óscar Fuentes <ofv@wanadoo.es>
> Date: Thu, 23 Jun 2016 04:28:47 +0200
> 
> This works on the Windows XP shell (cmd.exe):
> 
> C:\> chcp 65001
> C:\> grep λ *.txt
> λfoo
> 
> (grep.exe is from MSYS2 and the .txt file encoding is utf-8).

IOW, this grep.exe is a Cygwin program (MSYS2 is a fork of Cygwin),
and thus supports UTF-8 locales, like Cygwin does.

> However, M-x grep from Emacs displays no results ("Grep finished with no
> matches found...").

Yes, because the native Windows build of Emacs always encodes the
command-line arguments of programs it invokes using the current system
ANSI codepage.  And the system codepage cannot be set to 65001,
because support for that codepage in Windows is half-hearted: for
example, it cannot be used as the codeset in the arguments to
'setlocale' functions.  Which means any native Windows program will be
unable to correctly handle UTF-8 encoded characters, since the data
used by C runtime functions that compare, collate, and otherwise
process characters will not behave as you expect.

> Is there a method for executing shell commands encoded in utf-8 from
> Emacs on Windows?

Sadly, no.  Not until Windows improves their support for the UTF-8
codepage, such that it becomes a first-class citizen (and then we will
have a not-so-easy job of adapting to that in Emacs).  Until then, if
you want UTF-8 communications with subprocesses, use the Cygwin build
of Emacs.



  reply	other threads:[~2016-06-23 15:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-23  2:28 MS Windows: utf-8 in command line Óscar Fuentes
2016-06-23 15:21 ` Eli Zaretskii [this message]
2016-06-23 15:47   ` Óscar Fuentes

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=83oa6s2anl.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /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.
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).