[OS X Emacs] Re: ISO-8859-1 to UTF-8? (was: NSEmacs: copying and pasting long lines without the backslash)
Lloyd Zusman
ljz at asfast.com
Sun Nov 2 14:59:53 EST 2008
Lloyd Zusman <ljz <at> asfast.com> writes:
> [ ... ] This begs a new question: is there
> a function in Emacs 23.0.60.1 which will convert an ISO-8859-1 string
> into UTF-8? [ ... ]
I figured it out:
(defun my-convert-for-ns-emacs-kill-buffer (text)
(decode-coding-string
(string-as-unibyte (encode-coding-string (string-as-multibyte text) 'utf-8))
'iso-8859-1))
(defadvice kill-region
(around kill-region freeze)
(let ((buffer-substring-filters (list 'my-convert-for-ns-emacs-kill-buffer)))
ad-do-it))
(defadvice kill-ring-save
(around kill-ring-save freeze)
(let ((buffer-substring-filters (list 'my-convert-for-ns-emacs-kill-buffer)))
ad-do-it))
(defadvice ns-copy-including-secondary
(around ns-copy-including-secondary freeze)
(let ((buffer-substring-filters (list 'my-convert-for-ns-emacs-kill-buffer)))
ad-do-it))
This causes all of the cutting and copying operations in NSEmacs to
copy the text into the emacs kill buffer and also into the Mac's
paste buffer in a format that allows me to paste it into other
applications, even if it contains 8-bit characters.
--
Lloyd Zusman
ljz at asfast.com
God bless you.
More information about the MacOSX-Emacs
mailing list