Ken Thomases : winemac: Convert old-Mac-style line breaks (CR) to Windows-style CRLF when importing UTF-16.

Alexandre Julliard julliard at winehq.org
Mon Oct 24 15:57:54 CDT 2016


Module: wine
Branch: master
Commit: e846da321abc02560dadbd50435d0444f0575f8e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e846da321abc02560dadbd50435d0444f0575f8e

Author: Ken Thomases <ken at codeweavers.com>
Date:   Sun Oct 23 13:03:21 2016 -0500

winemac: Convert old-Mac-style line breaks (CR) to Windows-style CRLF when importing UTF-16.

At least one Mac app, TextWrangler, puts UTF-16 data on the pasteboard with
lines separated by CR (although it uses LF for the UTF-8 form of the same text).
Other Mac apps handle it properly; we should, too.

Signed-off-by: Ken Thomases <ken at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winemac.drv/clipboard.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c
index 72aed3a..bdbd62e 100644
--- a/dlls/winemac.drv/clipboard.c
+++ b/dlls/winemac.drv/clipboard.c
@@ -1176,6 +1176,8 @@ static HANDLE import_utf16_to_unicodetext(CFDataRef data)
     {
         if (src[i] == '\n')
             new_lines++;
+        else if (src[i] == '\r' && (i + 1 >= src_len || src[i + 1] != '\n'))
+            new_lines++;
     }
 
     if ((unicode_handle = GlobalAlloc(GMEM_FIXED, (src_len + new_lines + 1) * sizeof(WCHAR))))
@@ -1188,6 +1190,9 @@ static HANDLE import_utf16_to_unicodetext(CFDataRef data)
                 dst[j++] = '\r';
 
             dst[j++] = src[i];
+
+            if (src[i] == '\r' && (i + 1 >= src_len || src[i + 1] != '\n'))
+                dst[j++] = '\n';
         }
         dst[j] = 0;
 




More information about the wine-cvs mailing list