From: Eli Zaretskii Date: Tue, 3 Dec 2013 12:21:13 +0000 (+0200) Subject: Fixed drag-n-drop with Unicode file names. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~446^2~25 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d45c90885962da97a8d72d2ffb8ce38046d8cb58;p=emacs.git Fixed drag-n-drop with Unicode file names. --- diff --git a/lisp/dnd.el b/lisp/dnd.el index d9061273c32..a4aa4f4558e 100644 --- a/lisp/dnd.el +++ b/lisp/dnd.el @@ -152,10 +152,13 @@ Return nil if URI is not a local file." (let ((f (cond ((string-match "^file:///" uri) ; XDND format. (substring uri (1- (match-end 0)))) ((string-match "^file:" uri) ; Old KDE, Motif, Sun - (substring uri (match-end 0)))))) - (and f (setq f (decode-coding-string (dnd-unescape-uri f) - (or file-name-coding-system - default-file-name-coding-system)))) + (substring uri (match-end 0))))) + (coding (if (equal system-type 'windows-nt) + ;; W32 pretends that file names are UTF-8 encoded. + 'utf-8 + (or file-name-coding-system + default-file-name-coding-system)))) + (and f (setq f (decode-coding-string (dnd-unescape-uri f) coding))) (when (and f must-exist (not (file-readable-p f))) (setq f nil)) f)) diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index ff654f23747..461a0543829 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -723,9 +723,12 @@ interactively. Turn the filename into a URL with function (defun browse-url-file-url (file) "Return the URL corresponding to FILE. Use variable `browse-url-filename-alist' to map filenames to URLs." - (let ((coding (and (default-value 'enable-multibyte-characters) - (or file-name-coding-system - default-file-name-coding-system)))) + (let ((coding (if (equal system-type 'windows-nt) + ;; W32 pretends that file names are UTF-8 encoded. + 'utf-8 + (and (default-value 'enable-multibyte-characters) + (or file-name-coding-system + default-file-name-coding-system))))) (if coding (setq file (encode-coding-string file coding)))) (setq file (browse-url-url-encode-chars file "[*\"()',=;?% ]")) (dolist (map browse-url-filename-alist) diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el index 513a99d4914..af1a351c0ad 100644 --- a/lisp/term/w32-win.el +++ b/lisp/term/w32-win.el @@ -110,8 +110,13 @@ (let ((f (if (eq system-type 'cygwin) (cygwin-convert-file-name-from-windows file-name t) (subst-char-in-string ?\\ ?/ file-name))) - (coding (or file-name-coding-system - default-file-name-coding-system))) + (coding (if (eq system-type 'windows-nt) + ;; Native w32 build pretends that its file names + ;; are encoded in UTF-8, and converts to the + ;; appropriate encoding internally. + 'utf-8 + (or file-name-coding-system + default-file-name-coding-system)))) (setq file-name (mapconcat 'url-hexify-string