From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Why does dired go through extra efforts to avoid unibyte names Date: Fri, 29 Dec 2017 21:17:29 +0200 Message-ID: <83lghlfinq.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1514575019 24640 195.159.176.226 (29 Dec 2017 19:16:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 29 Dec 2017 19:16:59 +0000 (UTC) Cc: Kenichi Handa , emacs-devel@gnu.org, handa@m17n.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 29 20:16:55 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eV09D-0005nI-La for ged-emacs-devel@m.gmane.org; Fri, 29 Dec 2017 20:16:51 +0100 Original-Received: from localhost ([::1]:51550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eV0BC-0005NV-3z for ged-emacs-devel@m.gmane.org; Fri, 29 Dec 2017 14:18:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eV0AC-0005MY-O2 for emacs-devel@gnu.org; Fri, 29 Dec 2017 14:17:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eV0AA-0005Qq-Da for emacs-devel@gnu.org; Fri, 29 Dec 2017 14:17:51 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eV0A6-0005NA-Eh; Fri, 29 Dec 2017 14:17:46 -0500 Original-Received: from [176.228.60.248] (port=3507 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eV0A5-0008Ct-KO; Fri, 29 Dec 2017 14:17:46 -0500 In-reply-to: (message from Stefan Monnier on Fri, 29 Dec 2017 09:34:53 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221456 Archived-At: > From: Stefan Monnier > Date: Fri, 29 Dec 2017 09:34:53 -0500 > Cc: emacs-devel@gnu.org > > I bumped into the following code in dired-get-filename: > > ;; The above `read' will return a unibyte string if FILE > ;; contains eight-bit-control/graphic characters. > (if (and enable-multibyte-characters > (not (multibyte-string-p file))) > (setq file (string-to-multibyte file))) > > and I'm wondering why we don't want a unibyte string here. > `vc-region-history` told me this comes from the commit appended below, > which seems to indicate that we're worried about a subsequent encoding, > but AFAIK unibyte file names are not (re)encoded, and passing them > through string-to-multibyte would actually make things worse in this > respect (since it might cause the kind of (re)encoding this is > supposedly trying to avoid). > > What am I missing? Why does it matter whether eight-bit-* characters are encoded one more or one less time? As for the reason for using string-to-multibyte: maybe it's because we use concat further down in the function, which will determine whether the result will be unibyte or multibyte according to its own ideas of what's TRT?