emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OS X: additional characters copied to clipboard


From: YAMAMOTO Mitsuharu
Subject: Re: OS X: additional characters copied to clipboard
Date: Fri, 14 Oct 2005 12:32:52 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/22.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Thu, 13 Oct 2005 23:22:58 +0100, David Reitter <address@hidden> said:

> Copying a region with a number to the clipboard means that some
> additional characters seem to be copied.  

That's BOM (Byte Order Mark) for UTF-16.  Could you try the following
patch?

                                     YAMAMOTO Mitsuharu
                                address@hidden

Index: lisp/term/mac-win.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/term/mac-win.el,v
retrieving revision 1.54
diff -c -r1.54 mac-win.el
*** lisp/term/mac-win.el        1 Oct 2005 11:07:39 -0000       1.54
--- lisp/term/mac-win.el        14 Oct 2005 03:27:55 -0000
***************
*** 1198,1212 ****
      (when (and (stringp data)
               (setq data-type (get-text-property 0 'foreign-selection data)))
        (cond ((eq data-type 'public.utf16-plain-text)
!            (let ((encoded (and (fboundp 'mac-code-convert-string)
!                                (mac-code-convert-string data
!                                                         'utf-16 coding))))
!              (if encoded
!                  (let ((coding-save last-coding-system-used))
!                    (setq data (decode-coding-string encoded coding))
!                    (setq last-coding-system-used coding-save))
!                (setq data
!                      (decode-coding-string data 'utf-16)))))
            ((eq data-type 'com.apple.traditional-mac-plain-text)
             (setq data (decode-coding-string data coding)))
            ((eq data-type 'public.file-url)
--- 1198,1218 ----
      (when (and (stringp data)
               (setq data-type (get-text-property 0 'foreign-selection data)))
        (cond ((eq data-type 'public.utf16-plain-text)
!            (if (fboundp 'mac-code-convert-string)
!                (let ((s (mac-code-convert-string data 'utf-16 coding)))
!                  (if s
!                      (setq data (decode-coding-string s coding))
!                    (setq data
!                          ;; (decode-coding-string data 'utf-16) is
!                          ;; not correct because
!                          ;; public.utf16-plain-text is defined as
!                          ;; native byte order, no BOM.
!                          (decode-coding-string
!                           (mac-code-convert-string data 'utf-16 'utf-8)
!                           'utf-8))))
!              ;; No `mac-code-convert-string' means non-Carbon, which
!              ;; implies big endian.
!              (setq data (decode-coding-string data 'utf-16be))))
            ((eq data-type 'com.apple.traditional-mac-plain-text)
             (setq data (decode-coding-string data coding)))
            ((eq data-type 'public.file-url)
***************
*** 1323,1336 ****
          (remove-text-properties 0 (length str) '(composition nil) str)
          (cond
           ((eq type 'public.utf16-plain-text)
!           (let (s)
!             (when (and (fboundp 'mac-code-convert-string)
!                        (memq coding (find-coding-systems-string str)))
!               (setq coding (coding-system-change-eol-conversion coding 'mac))
!               (setq s (mac-code-convert-string
!                        (encode-coding-string str coding)
!                        coding 'utf-16)))
!             (setq str (or s (encode-coding-string str 'utf-16-mac)))))
           ((eq type 'com.apple.traditional-mac-plain-text)
            (let ((encodables (find-coding-systems-string str))
                  (rest mac-script-code-coding-systems))
--- 1329,1353 ----
          (remove-text-properties 0 (length str) '(composition nil) str)
          (cond
           ((eq type 'public.utf16-plain-text)
!           (if (fboundp 'mac-code-convert-string)
!               (let (s)
!                 (when (memq coding (find-coding-systems-string str))
!                   (setq coding
!                         (coding-system-change-eol-conversion coding 'mac))
!                   (setq s (mac-code-convert-string
!                            (encode-coding-string str coding)
!                            coding 'utf-16)))
!                 (setq str (or s
!                               ;; (encode-coding-string str
!                               ;; 'utf-16-mac) is not correct because
!                               ;; public.utf16-plain-text is defined
!                               ;; as native byte order, no BOM.
!                               (mac-code-convert-string
!                                (encode-coding-string str 'utf-8-mac)
!                                'utf-8 'utf-16))))
!             ;; No `mac-code-convert-string' means non-Carbon, which
!             ;; implies big endian.
!             (setq str (encode-coding-string str 'utf-16be-mac))))
           ((eq type 'com.apple.traditional-mac-plain-text)
            (let ((encodables (find-coding-systems-string str))
                  (rest mac-script-code-coding-systems))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]