directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1758860 - /directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
Date Thu, 01 Sep 2016 21:54:59 GMT
Author: seelmann
Date: Thu Sep  1 21:54:59 2016
New Revision: 1758860

URL: http://svn.apache.org/viewvc?rev=1758860&view=rev
Log:
DIRSTUDIO-1114: Bad encoding used in text editor for binary data. Use UTF-8 encoding for converting
byte[] to String.

Modified:
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java?rev=1758860&r1=1758859&r2=1758860&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
Thu Sep  1 21:54:59 2016
@@ -24,6 +24,7 @@ package org.apache.directory.studio.ldap
 import java.io.File;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.directory.api.util.FileUtils;
 import org.apache.directory.studio.common.ui.CommonUIUtils;
@@ -103,7 +104,7 @@ public class HexDialog extends Dialog
             // Checking if the data is "text-editable"
             if ( isEditable( currentData ) )
             {
-                TextDialog dialog = new TextDialog( getShell(), new String( currentData )
);
+                TextDialog dialog = new TextDialog( getShell(), new String( currentData,
StandardCharsets.UTF_8 ) );
 
                 if ( dialog.open() == TextDialog.OK )
                 {
@@ -177,14 +178,7 @@ public class HexDialog extends Dialog
             return false;
         }
 
-        try
-        {
-            return !( new String( b, "UTF-8" ).contains( "\uFFFD" ) );
-        }
-        catch ( UnsupportedEncodingException e )
-        {
-            return false;
-        }
+        return !( new String( b, StandardCharsets.UTF_8 ).contains( "\uFFFD" ) );
     }
 
 



Mime
View raw message