summaryrefslogtreecommitdiff
path: root/lisp/x-dnd.el
diff options
context:
space:
mode:
authorJan Djärv <jan.h.d@swipnet.se>2004-04-02 17:29:52 +0000
committerJan Djärv <jan.h.d@swipnet.se>2004-04-02 17:29:52 +0000
commitb694166c1f52f0db4a3cb6bf960a9671d4ba5120 (patch)
tree5c1684f379ccb3ba6876ee347a1e1b8945337b53 /lisp/x-dnd.el
parent6e4acfae63d2640a9720a60830e2cef387cb4b16 (diff)
downloademacs-b694166c1f52f0db4a3cb6bf960a9671d4ba5120.tar.gz
* x-dnd.el (x-dnd-handle-moz-url, x-dnd-insert-utf16-text): Use
utf-16le on little endian machines and utf-16be otherwise.
Diffstat (limited to 'lisp/x-dnd.el')
-rw-r--r--lisp/x-dnd.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/lisp/x-dnd.el b/lisp/x-dnd.el
index 91ca053afa2..cdb0a63ace6 100644
--- a/lisp/x-dnd.el
+++ b/lisp/x-dnd.el
@@ -336,7 +336,12 @@ WINDOW is the window where the drop happened. ACTION is ignored.
DATA is the moz-url, which is formatted as two strings separated by \r\n.
The first string is the URL, the second string is the title of that URL.
DATA is encoded in utf-16. Decode the URL and call `x-dnd-handle-uri-list'."
- (let* ((string (decode-coding-string data 'utf-16le)) ;; ALWAYS LE???
+ ;; Mozilla and applications based on it (Galeon for example) uses
+ ;; text/unicode, but it is impossible to tell if it is le or be. Use what
+ ;; the machine Emacs runs on use. This looses if dropping between machines
+ ;; with different endian, but it is the best we can do.
+ (let* ((coding (if (eq (byteorder) ?B) 'utf-16be 'utf-16le))
+ (string (decode-coding-string data coding))
(strings (split-string string "[\r\n]" t))
;; Can one drop more than one moz-url ?? Assume not.
(url (car strings))
@@ -351,7 +356,9 @@ TEXT is the text as a string, WINDOW is the window where the drop happened."
(defun x-dnd-insert-utf16-text (window action text)
"Decode the UTF-16 text and insert it at point.
TEXT is the text as a string, WINDOW is the window where the drop happened."
- (x-dnd-insert-text window action (decode-coding-string text 'utf-16le)))
+ ;; See comment in x-dnd-handle-moz-url about coding.
+ (let ((coding (if (eq (byteorder) ?B) 'utf-16be 'utf-16le)))
+ (x-dnd-insert-text window action (decode-coding-string text coding))))
(defun x-dnd-insert-ctext (window action text)
"Decode the compound text and insert it at point.