You've probably noticed that if you try to paste a Latin1 character
such as "£" from Mozilla to XEmacs, you get a question-mark instead.
This is a bug in Mozilla that I reported a while ago
(
http://bugzilla.mozilla.org/show_bug.cgi?id=136004) but I got
tired of waiting around for them to fix it, so I kluged a workaround:
before asking for the 'STRING target, check for the 'text/unicode
target.
But, I don't know anything about Unicode, so what I did to convert
it to Latin1 was just to delete every other byte. I leave the right
implementation to those who know/care...
(defun x-insert-selection (&optional check-cutbuffer-p move-point-event)
"Insert the current selection into buffer at point."
(interactive "P")
(let* ((unicode-p nil)
(text (or (condition-case ()
(prog1 (x-get-selection nil 'text/unicode)
(setq unicode-p t))
(error ()))
(x-get-selection))))
(cond (move-point-event
(mouse-set-point move-point-event)
(push-mark (point)))
((interactive-p)
(push-mark (point))))
(let ((p (point)))
(insert text)
(if unicode-p
;; When mozilla gives us unicode strings, the Latin1 characters
;; are in the top 8 bits of a 16 bit character: the bottom 8 bits
;; are null. Delete them. This is not even close to being a
;; proper Unicode parser, but at least it lets me paste Latin1
;; characters from Mozilla 1.1b to XEmacs 21.1.
(save-excursion
(while (> (point) p)
(delete-char -1)
(forward-char -1))))
text)))
--
Jamie Zawinski
jwz(a)jwz.org
http://www.jwz.org/
jwz(a)dnalounge.com
http://www.dnalounge.com/