From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: ISO-8859-1 encoded file names and UTF-8 Date: Wed, 19 Mar 2003 22:33:35 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200303191333.WAA29877@etlken.m17n.org> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: main.gmane.org 1048080935 31027 80.91.224.249 (19 Mar 2003 13:35:35 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 19 Mar 2003 13:35:35 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Mar 19 14:35:33 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18vdjB-00084J-00 for ; Wed, 19 Mar 2003 14:35:33 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18vdjx-0003Wr-00 for ; Wed, 19 Mar 2003 14:36:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18vdhn-00016x-09 for emacs-devel@quimby.gnus.org; Wed, 19 Mar 2003 08:34:07 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18vdhS-00012T-00 for emacs-devel@gnu.org; Wed, 19 Mar 2003 08:33:46 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18vdhQ-00011z-00 for emacs-devel@gnu.org; Wed, 19 Mar 2003 08:33:45 -0500 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18vdhP-000110-00 for emacs-devel@gnu.org; Wed, 19 Mar 2003 08:33:44 -0500 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])h2JDXZ907271; Wed, 19 Mar 2003 22:33:35 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) h2JDXZA08980; Wed, 19 Mar 2003 22:33:35 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id WAA29877; Wed, 19 Mar 2003 22:33:35 +0900 (JST) Original-To: keichwa@gmx.net In-reply-to: (message from Karl Eichwalder on Sat, 08 Mar 2003 07:15:56 +0100) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:12465 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:12465 I'm sorry for the late response. Before providing a solution, I had to fix some fundamental problems about filename handling. In article , Karl Eichwalder writes: > UTF-8 Emacs sometimes fails to manage ISO-8859-1 file names. I do not > know how you can rename or convert these file name from ISO-8859-1 to > UTF-8 encoded names using Emacs. Hmmm, I think it's a completely overlooked but important feature. > I created some ISO-8859-1 encoded file names (on top of the ext2 file > system). Start a UTF-8 Emacs: > LANG=de_DE.UTF-8 emacs > Call dired on the directory containing these files; you will see > something like (attention, Emacs/Gnus will normalize the names when I > send the mail!): [...] > Note, the buffer is marked "-u" in the modeline. > Now go to a file name with umlauts and press 'f' to visit the file: > Debugger entered--Lisp error: (error "File no longer exists; type `g' to update Dired buffer") This problem should be fixed now in HEAD. Please try again after updating from CVS. Anyway, how about the attached function for changing the encoding of a filename. I have not yet installed it because I have not yet found an answer to this question. Should the recoding of filename regarded as a kind of file name changing? If so, perhaps we should make the function rename-file to handle also recoding. In that case, how should we tell rename-file to actually recode filename encoding? --- Ken'ichi HANDA handa@m17n.org (defun recode-file (file coding new-coding &optional ok-if-already-exists) (interactive (let* ((default (or file-name-coding-system default-file-name-coding-system)) (filename (read-file-name "Recode file: " nil nil t)) (from-coding (if (and default ;; We provide the default coding only when it ;; seems that the filename is correctly decoded by ;; the default coding. (let ((charsets (find-charset-string filename))) (and (not (memq 'eight-bit-control charsets)) (not (memq 'eight-bit-graphic charsets))))) (read-coding-system (format "Recode file %s from coding (default %s): " filename default) default) (read-coding-system (format "Recode file %s from coding: " filename)))) (to-coding ;; We provide the default coding only when a user is going ;; to change the encoding not from the default coding. (if (eq from-coding default) (read-coding-system (format "Recode file %s from coding %s to coding: " filename from-coding)) (read-coding-system (format "Recode file %s from coding %s to coding (default %s): " filename from-coding default) default)))) (list filename from-coding to-coding))) (let* ((default (or file-name-coding-system default-file-name-coding-system)) (encoded (encode-coding-string file default)) (new-encoded (encode-coding-string (decode-coding-string encoded coding) new-coding)) (file-name-coding-system nil) (default-file-name-coding-system nil) (locale-coding-system nil)) (rename-file encoded new-encoded ok-if-already-exists)))