From a41bc73423b6b11d265028bc7e9bc7ab0790cf59 Mon Sep 17 00:00:00 2001 From: Manajit Halder Date: Fri, 11 Nov 2016 13:58:42 +0530 Subject: [PATCH] 8165680: [macosx] Enhance handling of UTF-8 characters in CDataTransfer.java Reviewed-by: serb, aniyogi --- .../macosx/classes/sun/lwawt/macosx/CDataTransferer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java index 150c6e92ad1..795e4296c70 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java @@ -38,6 +38,7 @@ import java.text.Normalizer.Form; 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 @@ public class CDataTransferer extends DataTransferer { 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) { } }