8165680: [macosx] Enhance handling of UTF-8 characters in CDataTransfer.java
Reviewed-by: serb, aniyogi
Contributed-by: manajit.halder@oracle.com
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Fri Nov 11 12:40:59 2016 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Fri Nov 11 13:58:42 2016 +0530
@@ -38,6 +38,7 @@
import java.util.*;
import java.util.regex.*;
import java.awt.datatransfer.*;
+import java.nio.charset.StandardCharsets;
import sun.awt.datatransfer.*;
public class CDataTransferer extends DataTransferer {
@@ -132,7 +133,7 @@
String charset = Charset.defaultCharset().name();
if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) {
try {
- charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), "UTF-8");
+ charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), StandardCharsets.UTF_8);
} catch (UnsupportedFlavorException cannotHappen) {
}
}