| Summary: | HTML on Clipboard appears as raw HTML in TextEdit | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Craig Reichenbach <creichen> |
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | creichen, kleind, linyunz, mukund, pfancdl, pwebster, remy.suen, Silenio_Quarti, tpwinkle |
| Version: | 3.6.2 | ||
| Target Milestone: | --- | ||
| Hardware: | Macintosh | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
|
Description
Craig Reichenbach
I think this problem caused by HTMLTransfer in swt-carbon,swt-cocoa hasn't this problem.
In carbon HTMLTransfer.javaToNative,It use the following code to transfer the String object to an byte array.
string.getChars(0, count, chars, 0);
byte[] buffer = new byte[chars.length * 2];
OS.memmove(buffer, chars, buffer.length);
transferData.data = new byte[1][];
transferData.data[0] = buffer;
I have debug these code,it will transfer the String to an byte array use charset "UTF-16LE" in MAC.
The "UTF-16LE" and "UTF-16BE" charset hasn't the "Byte order mark" character at the beginning of the array.So the MAC can not decode these two charsets correctly,It cause this problem.
If we use String.getBytes("UTF-8") or String.getBytes("UTF-16") instead the String-byte array transfer code in HTMLTransfer.javaToNative, It will works correctly.We can also add "Byte order mark" character at the beginning of the UTF-16LE/UTF-16BE array to fixed this problem.
FYI:
Input html String:
<html><head></head><body><div
id=\"ltsample\">This is some <i>html</i> text. My phone number is
<b>234-234-2342</b></div></body></html>
UTF-8 byte array of this String(can be decoded successfully):
[60, 104, 116, 109, 108, 62, 60, 104, 101, 97, 100, 62, 60, 47, 104, 101, 97, 100, 62, 60, 98, 111, 100, 121, 62, 60, 100, 105, 118, 32, 105, 100, 61, 34, 108, 116, 115, 97, 109, 112, 108, 101, 34, 62, 84, 104, 105, 115, 32, 105, 115, 32, 115, 111, 109, 101, 32, 60, 105, 62, 104, 116, 109, 108, 60, 47, 105, 62, 32, 116, 101, 120, 116, 46, 32, 32, 77, 121, 32, 112, 104, 111, 110, 101, 32, 110, 117, 109, 98, 101, 114, 32, 105, 115, 32, 60, 98, 62, 50, 51, 52, 45, 50, 51, 52, 45, 50, 51, 52, 50, 60, 47, 98, 62, 60, 47, 100, 105, 118, 62, 60, 47, 98, 111, 100, 121, 62, 60, 47, 104, 116, 109, 108, 62]
UTF-16 byte array of this String(can be decoded successfully, the first two elements is "Byte order mark"):
[-2, -1, 0, 60, 0, 104, 0, 116, 0, 109, 0, 108, 0, 62, 0, 60, 0, 104, 0, 101, 0, 97, 0, 100, 0, 62, 0, 60, 0, 47, 0, 104, 0, 101, 0, 97, 0, 100, 0, 62, 0, 60, 0, 98, 0, 111, 0, 100, 0, 121, 0, 62, 0, 60, 0, 100, 0, 105, 0, 118, 0, 32, 0, 105, 0, 100, 0, 61, 0, 34, 0, 108, 0, 116, 0, 115, 0, 97, 0, 109, 0, 112, 0, 108, 0, 101, 0, 34, 0, 62, 0, 84, 0, 104, 0, 105, 0, 115, 0, 32, 0, 105, 0, 115, 0, 32, 0, 115, 0, 111, 0, 109, 0, 101, 0, 32, 0, 60, 0, 105, 0, 62, 0, 104, 0, 116, 0, 109, 0, 108, 0, 60, 0, 47, 0, 105, 0, 62, 0, 32, 0, 116, 0, 101, 0, 120, 0, 116, 0, 46, 0, 32, 0, 32, 0, 77, 0, 121, 0, 32, 0, 112, 0, 104, 0, 111, 0, 110, 0, 101, 0, 32, 0, 110, 0, 117, 0, 109, 0, 98, 0, 101, 0, 114, 0, 32, 0, 105, 0, 115, 0, 32, 0, 60, 0, 98, 0, 62, 0, 50, 0, 51, 0, 52, 0, 45, 0, 50, 0, 51, 0, 52, 0, 45, 0, 50, 0, 51, 0, 52, 0, 50, 0, 60, 0, 47, 0, 98, 0, 62, 0, 60, 0, 47, 0, 100, 0, 105, 0, 118, 0, 62, 0, 60, 0, 47, 0, 98, 0, 111, 0, 100, 0, 121, 0, 62, 0, 60, 0, 47, 0, 104, 0, 116, 0, 109, 0, 108, 0, 62]
UTF-16BE(can not be decoded successfully)
[0, 60, 0, 104, 0, 116, 0, 109, 0, 108, 0, 62, 0, 60, 0, 104, 0, 101, 0, 97, 0, 100, 0, 62, 0, 60, 0, 47, 0, 104, 0, 101, 0, 97, 0, 100, 0, 62, 0, 60, 0, 98, 0, 111, 0, 100, 0, 121, 0, 62, 0, 60, 0, 100, 0, 105, 0, 118, 0, 32, 0, 105, 0, 100, 0, 61, 0, 34, 0, 108, 0, 116, 0, 115, 0, 97, 0, 109, 0, 112, 0, 108, 0, 101, 0, 34, 0, 62, 0, 84, 0, 104, 0, 105, 0, 115, 0, 32, 0, 105, 0, 115, 0, 32, 0, 115, 0, 111, 0, 109, 0, 101, 0, 32, 0, 60, 0, 105, 0, 62, 0, 104, 0, 116, 0, 109, 0, 108, 0, 60, 0, 47, 0, 105, 0, 62, 0, 32, 0, 116, 0, 101, 0, 120, 0, 116, 0, 46, 0, 32, 0, 32, 0, 77, 0, 121, 0, 32, 0, 112, 0, 104, 0, 111, 0, 110, 0, 101, 0, 32, 0, 110, 0, 117, 0, 109, 0, 98, 0, 101, 0, 114, 0, 32, 0, 105, 0, 115, 0, 32, 0, 60, 0, 98, 0, 62, 0, 50, 0, 51, 0, 52, 0, 45, 0, 50, 0, 51, 0, 52, 0, 45, 0, 50, 0, 51, 0, 52, 0, 50, 0, 60, 0, 47, 0, 98, 0, 62, 0, 60, 0, 47, 0, 100, 0, 105, 0, 118, 0, 62, 0, 60, 0, 47, 0, 98, 0, 111, 0, 100, 0, 121, 0, 62, 0, 60, 0, 47, 0, 104, 0, 116, 0, 109, 0, 108, 0, 62]
UTF-16LE(can not be decoded successfully)
[60, 0, 104, 0, 116, 0, 109, 0, 108, 0, 62, 0, 60, 0, 104, 0, 101, 0, 97, 0, 100, 0, 62, 0, 60, 0, 47, 0, 104, 0, 101, 0, 97, 0, 100, 0, 62, 0, 60, 0, 98, 0, 111, 0, 100, 0, 121, 0, 62, 0, 60, 0, 100, 0, 105, 0, 118, 0, 32, 0, 105, 0, 100, 0, 61, 0, 34, 0, 108, 0, 116, 0, 115, 0, 97, 0, 109, 0, 112, 0, 108, 0, 101, 0, 34, 0, 62, 0, 84, 0, 104, 0, 105, 0, 115, 0, 32, 0, 105, 0, 115, 0, 32, 0, 115, 0, 111, 0, 109, 0, 101, 0, 32, 0, 60, 0, 105, 0, 62, 0, 104, 0, 116, 0, 109, 0, 108, 0, 60, 0, 47, 0, 105, 0, 62, 0, 32, 0, 116, 0, 101, 0, 120, 0, 116, 0, 46, 0, 32, 0, 32, 0, 77, 0, 121, 0, 32, 0, 112, 0, 104, 0, 111, 0, 110, 0, 101, 0, 32, 0, 110, 0, 117, 0, 109, 0, 98, 0, 101, 0, 114, 0, 32, 0, 105, 0, 115, 0, 32, 0, 60, 0, 98, 0, 62, 0, 50, 0, 51, 0, 52, 0, 45, 0, 50, 0, 51, 0, 52, 0, 45, 0, 50, 0, 51, 0, 52, 0, 50, 0, 60, 0, 47, 0, 98, 0, 62, 0, 60, 0, 47, 0, 100, 0, 105, 0, 118, 0, 62, 0, 60, 0, 47, 0, 98, 0, 111, 0, 100, 0, 121, 0, 62, 0, 60, 0, 47, 0, 104, 0, 116, 0, 109, 0, 108, 0, 62, 0]
UTF-16LE(can be decoded successfully, added "Byte order mark" manually)
[-1, -2, 60, 0, 104, 0, 116, 0, 109, 0, 108, 0, 62, 0, 60, 0, 104, 0, 101, 0, 97, 0, 100, 0, 62, 0, 60, 0, 47, 0, 104, 0, 101, 0, 97, 0, 100, 0, 62, 0, 60, 0, 98, 0, 111, 0, 100, 0, 121, 0, 62, 0, 60, 0, 100, 0, 105, 0, 118, 0, 32, 0, 105, 0, 100, 0, 61, 0, 34, 0, 108, 0, 116, 0, 115, 0, 97, 0, 109, 0, 112, 0, 108, 0, 101, 0, 34, 0, 62, 0, 84, 0, 104, 0, 105, 0, 115, 0, 32, 0, 105, 0, 115, 0, 32, 0, 115, 0, 111, 0, 109, 0, 101, 0, 32, 0, 60, 0, 105, 0, 62, 0, 104, 0, 116, 0, 109, 0, 108, 0, 60, 0, 47, 0, 105, 0, 62, 0, 32, 0, 116, 0, 101, 0, 120, 0, 116, 0, 46, 0, 32, 0, 32, 0, 77, 0, 121, 0, 32, 0, 112, 0, 104, 0, 111, 0, 110, 0, 101, 0, 32, 0, 110, 0, 117, 0, 109, 0, 98, 0, 101, 0, 114, 0, 32, 0, 105, 0, 115, 0, 32, 0, 60, 0, 98, 0, 62, 0, 50, 0, 51, 0, 52, 0, 45, 0, 50, 0, 51, 0, 52, 0, 45, 0, 50, 0, 51, 0, 52, 0, 50, 0, 60, 0, 47, 0, 98, 0, 62, 0, 60, 0, 47, 0, 100, 0, 105, 0, 118, 0, 62, 0, 60, 0, 47, 0, 98, 0, 111, 0, 100, 0, 121, 0, 62, 0, 60, 0, 47, 0, 104, 0, 116, 0, 109, 0, 108, 0, 62, 0]
This is fix in 3.6.2 and e.7 already. *** This bug has been marked as a duplicate of bug 330122 *** meant to say 3.6.2 and 3.7... |