Subject: Re: bug#15426: 24.3.50; Multibyte filenames and directory-files in unibyte buffer

From: Andreas Politz <[email-masked]>
Date: Fri, 20 Sep 2013 22:56:22 +0200

Eli Zaretskii <[email-masked]> writes:

>> From: Stefan Monnier <[email-masked]>
>> Cc: Andreas Politz <[email-masked]>,  [email-masked]
>> Date: Fri, 20 Sep 2013 15:15:44 -0400
>> 
>> > Don't do that: inserting multibyte strings into a unibyte buffer
>> > changes the representation of the characters in the string, so you get
>> > a unibyte string.  Unibyte buffers should only ever hold encoded text
>> > or binary data.
>> 
>> AFAICT his recipe does not involve inserting any string anywhere.
>
> Perhaps the recipe should be described in more detail, then.

Here is another recipe, maybe more to the point:

-------------------->8-------------------------------------
;; -*- coding: binary -*-

(let ((d "/tmp/\303\204")) ;; utf-8 for german umlaut "A 
  (when (file-exists-p d)
    (delete-directory d t))
  (make-directory d)
  (append
   (list (car (directory-files d t)) 
         (file-exists-p (car (directory-files d t))))
   ;; switch to a multibyte buffer
   (with-temp-buffer
     (list (car (directory-files d t))
	   (file-exists-p (car (directory-files d t)))))))
--------------------8<-------------------------------------

If I save this somewhere (/tmp/foo.el), do

$ LC_ALL=C emacs -Q /tmp/foo.el

and evaluate it with C-x C-e, the minibuffer displays

=> ("/tmp/\301\203\300\204/." nil "/tmp/\303\204/." t)
 
.

I hope that clarifies it.

-ap