Subject: bug#69718: 29.2; grep japanese-iso-8bit-unix string fails with "grep: illegal byte sequence"

From: Eli Zaretskii <[email-masked]>
Date: Mon, 11 Mar 2024 14:50:31 +0200

> Cc: 白井彰 <[email-masked]>
> From: Akira Shirai <[email-masked]>
> Date: Mon, 11 Mar 2024 08:45:33 +0900
> 
> 1. emacs -Q on macOS
> 2. evaluate (set-language-environment "Japanese")
> 3. visit the directory where SKK-JISYO.L exists (ex. ~/emacs-29.2/leim/SKK-DIC/ )
> 4. type C-x RET c to run universal-coding-system-argument command, and specify japanese-iso-8bit-unix as the coding-system
> 5. type M-x grep to run grep, and specify "grep --color=auto -nH --null -e この辞書は SKK-JISYO.L" as the command-args
>   => grep fails with "grep: illegal byte sequence"
> 
> On emacs 29.1, the grep runs successfully with the same procedures.
> If the command-args is "LANG=C grep --color=auto -nH --null -e この辞書は SKK-JISYO.L", the grep runs successfully.

I cannot reproduce this, but I'm not on macOS.

We made a change in msterm.m between Emacs 29.1 and Emacs 29.2, which
might be responsible for this: we now set the Emacs locale
differently.  But I'm not sure what you see means there's a bug in
Emacs, because it could well be a bug in Grep that you have on macOS;
for example, this page:

  https://stackoverflow.com/questions/19242275/re-error-illegal-byte-sequence-on-mac-os-x

clearly hints that this might be the case, and that setting LANG=C is
indeed the right solution for this.