emacs-devel
[Top][All Lists]
Advanced

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

Fwd: Line endings bug


From: Seiji Zenitani
Subject: Fwd: Line endings bug
Date: Wed, 16 May 2007 21:01:25 -0400

Hi,

I received the following fix to the mac port. Although I have not yet met troubles regarding CR/LF, I think it makes sense to modify utf-16be/16le-mac to utf-16be/16le in the last two lines in mac- string-to-utxt, term/mac-win.el. The default eol character seems to be 'unix and I hear OS X's internal code is utf-16 + LF (unix). Could you please examine it?

==
Seiji Zenitani
address@hidden


Begin forwarded message:

The function mac-string-to-utxt (inside term/mac-win.el) is used to encode text which is then placed onto the system clipboard, It currently uses the encodings utf-16be-mac and/or utf-16le-mac which replace all \n characters with \r (0x0A with 0x0D), You can add the following to .emacs to fix this and preserve the correct newlines in the buffer/file:

(defun mac-string-to-utxt (string &optional coding-system)
 (or coding-system (setq coding-system mac-system-coding-system))
 (let (data encoding)
   (when (and (fboundp 'mac-code-convert-string)
              (memq (coding-system-base coding-system)
                    (find-coding-systems-string string)))
     (setq coding-system
           (coding-system-change-eol-conversion coding-system 'unix))
     (let ((str string))
       (when (and (eq system-type 'darwin)
                  (eq coding-system 'japanese-shift-jis-mac))
         (setq encoding mac-text-encoding-mac-japanese-basic-variant)
         (setq str (subst-char-in-string ?\\ ?\x80 str))
         (subst-char-in-string ?\\ ?\x5c str t)
         ;; ASCII-only?
         (if (string-match "\\`[\x00-\x7f]*\\'" str)
             (setq str nil)))
       (and str
            (setq data (mac-code-convert-string
                        (encode-coding-string str coding-system)
                        (or encoding coding-system) nil)))))
   (or data (encode-coding-string string (if (eq (byteorder) ?B)
                                             'utf-16be
                                           'utf-16le)))))

The only change is in the last two lines, removal of -mac in each.





reply via email to

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