[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ISO-8859-1 encoded file names and UTF-8
From: |
Kenichi Handa |
Subject: |
Re: ISO-8859-1 encoded file names and UTF-8 |
Date: |
Wed, 19 Mar 2003 22:33:35 +0900 (JST) |
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) |
I'm sorry for the late response. Before providing a solution, I had
to fix some fundamental problems about filename handling.
In article <address@hidden>, Karl Eichwalder <address@hidden> 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
address@hidden
(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)))
Re: ISO-8859-1 encoded file names and UTF-8,
Kenichi Handa <=
Re: ISO-8859-1 encoded file names and UTF-8, Richard Stallman, 2003/03/21
Re: ISO-8859-1 encoded file names and UTF-8, Richard Stallman, 2003/03/20