unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: call-process -> insert -> iso-latin-1-dos problem on Windows
Date: Sun, 14 Jan 2024 20:25:54 -0500	[thread overview]
Message-ID: <jwv34uze6rh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: CADs++6jc9BXPKqd8Ry5BA53zSvE4GvGeLjjJSomeng=OB-eMiw@mail.gmail.com

> I have a function called `find-wget' that works well in *NIX-like
> systems - it calls wget, puts the output in the temporary buffer, and
> on unices Emacs always chooses the right encoding... but when I run it
> on Windows, and I call wget like this,
>
>   wget -q -O - http://anggtwu.net/LUA/Dang1.lua
>
> where Dang1.lua is a file in UTF-8, then Emacs switches the encoding
> of output buffer to iso-latin-1-dos...

Most current POSIX systems use UTF-8 encoding by default.
AFAIK This is not the case under Windows.

> I probably wrote my code relying in undefined behaviors...

You generally need to tell Emacs what's the (expected) encoding of
a process's output.  Emacs generally assumes it's "the system's default"
if not, but that's bound to be wrong every once in a while.
You can do that by let-binding `coding-system-for-read`,
`process-coding-system-alist`, or `default-process-coding-system` around
the call to `call-process`.
For async processes you can do it more directly by passing a `:coding`
arg to to `make-process`.


        Stefan




  parent reply	other threads:[~2024-01-15  1:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-14 23:09 call-process -> insert -> iso-latin-1-dos problem on Windows Eduardo Ochs
2024-01-15  0:17 ` Michael Heerdegen via Users list for the GNU Emacs text editor
2024-01-15  1:25 ` Stefan Monnier via Users list for the GNU Emacs text editor [this message]
2024-01-15 12:34 ` 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=jwv34uze6rh.fsf-monnier+emacs@gnu.org \
    --to=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).