|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2017 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2025 IBM Corporation and others. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials |
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0 |
@@ -90,14 +90,26 @@ public void javaToNative (Object object, TransferData transferData){ |
90 | 90 | @Override |
91 | 91 | public Object nativeToJava(TransferData transferData){ |
92 | 92 | if ( !isSupportedType(transferData) || transferData.pValue == 0 ) return null; |
93 | | - /* Ensure byteCount is a multiple of 2 bytes */ |
94 | | - int size = (transferData.format * transferData.length / 8) / 2 * 2; |
| 93 | + |
| 94 | + int size = (transferData.format * transferData.length / 8); |
95 | 95 | if (size <= 0) return null; |
96 | 96 | char[] bom = new char[1]; // look for a Byte Order Mark |
97 | 97 | if (size > 1) C.memmove (bom, transferData.pValue, 2); |
98 | 98 | String string; |
99 | 99 | if (bom[0] == '\ufeff' || bom[0] == '\ufffe') { |
100 | | - // utf16 |
| 100 | + // XXX Follow up to Bugs 376589 384381 this is almost |
| 101 | + // certainly wrong as it leaves the BOM as the first |
| 102 | + // character in the string. This probably should be |
| 103 | + // |
| 104 | + // byte[] bytes = new byte [size]; |
| 105 | + // C.memmove (bytes, transferData.pValue, size); |
| 106 | + // string = new String(bytes, StandardCharset.UTF16); |
| 107 | + // |
| 108 | + // However I cannot find any current Linux program that |
| 109 | + // copies text/html to the clipboard in UTF16 anymore |
| 110 | + // so it is probably not a big issue |
| 111 | + /* Ensure byteCount is a multiple of 2 bytes */ |
| 112 | + size = size / 2 * 2; |
101 | 113 | char[] chars = new char [size/2]; |
102 | 114 | C.memmove (chars, transferData.pValue, size); |
103 | 115 | string = new String (chars); |
|
0 commit comments