8165680: [macosx] Enhance handling of UTF-8 characters in CDataTransfer.java
authormhalder
Fri, 11 Nov 2016 13:58:42 +0530
changeset 42211 ac4e6dc2d20f
parent 42210 7acd39aaf16f
child 42212 e5662f6598d4
8165680: [macosx] Enhance handling of UTF-8 characters in CDataTransfer.java Reviewed-by: serb, aniyogi Contributed-by: manajit.halder@oracle.com
jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java
--- 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) {
                 }
             }