-
Bug
-
Resolution: Fixed
-
P4
-
17, 18, 19
-
macOS 12.1
-
b08
-
os_x
When text is pasted from macOS system clipboard to a Java application, it is always converted to an NFC Unicode normalization form. This is unexpected, as it doesn't happen on pasting to native applications. To reproduce, open the attached sample.txt file in TextEdit, copy its contents to clipboard (Cmd+A, Cmd+C), then launch the following sample application:
==============
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
public class ClipboardTest {
public static void main(String[] args) throws Exception {
String content = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
for (int i = 0; i < content.length(); i++) {
System.out.println(Integer.toHexString(content.charAt(i)));
}
}
}
==============
Expected output (decomposed form, matching sample.txt file's content):
61
308
Actual output (composed form):
e4
The issue cannot be observed when pasting from TextEdit to another native macOS application, e.g. to Xcode (the same applies to copying from Xcode to TextEdit).
==============
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
public class ClipboardTest {
public static void main(String[] args) throws Exception {
String content = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
for (int i = 0; i < content.length(); i++) {
System.out.println(Integer.toHexString(content.charAt(i)));
}
}
}
==============
Expected output (decomposed form, matching sample.txt file's content):
61
308
Actual output (composed form):
e4
The issue cannot be observed when pasting from TextEdit to another native macOS application, e.g. to Xcode (the same applies to copying from Xcode to TextEdit).