From: Kenichi Handa <handa@m17n.org>
Cc: emacs-devel@gnu.org
Subject: Re: ISO-8859-1 encoded file names and UTF-8
Date: Wed, 19 Mar 2003 22:33:35 +0900 (JST) [thread overview]
Message-ID: <200303191333.WAA29877@etlken.m17n.org> (raw)
In-Reply-To: <shfzpy1izn.fsf@tux.gnu.franken.de> (message from Karl Eichwalder on Sat, 08 Mar 2003 07:15:56 +0100)
I'm sorry for the late response. Before providing a solution, I had
to fix some fundamental problems about filename handling.
In article <shfzpy1izn.fsf@tux.gnu.franken.de>, Karl Eichwalder <keichwa@gmx.net> 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)))
next prev parent reply other threads:[~2003-03-19 13:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-08 6:15 ISO-8859-1 encoded file names and UTF-8 Karl Eichwalder
2003-03-08 9:16 ` Eli Zaretskii
2003-03-08 10:05 ` Karl Eichwalder
2003-03-08 17:06 ` Eli Zaretskii
2003-03-08 18:25 ` Karl Eichwalder
2003-03-08 22:35 ` Eli Zaretskii
2003-03-09 4:38 ` Karl Eichwalder
2003-03-19 13:33 ` Kenichi Handa [this message]
2003-03-19 16:15 ` Karl Eichwalder
2003-03-19 23:52 ` Kenichi Handa
2003-03-20 17:32 ` Karl Eichwalder
2003-03-21 6:01 ` Kenichi Handa
2003-03-21 19:53 ` Karl Eichwalder
2003-03-21 19:06 ` Richard Stallman
2003-03-20 8:46 ` Richard Stallman
2003-03-20 9:11 ` Kenichi Handa
2003-03-23 2:52 ` Richard Stallman
2003-03-24 0:28 ` Kenichi Handa
2003-03-24 19:27 ` Richard Stallman
2003-03-26 4:47 ` Kenichi Handa
2003-04-01 21:17 ` etags and UTF-8 encoded file names (Re: ISO-8859-1 encoded file names and UTF-8) Karl Eichwalder
2003-04-02 1:34 ` Kenichi Handa
2003-04-02 19:26 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200303191333.WAA29877@etlken.m17n.org \
--to=handa@m17n.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.