directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r315052 - /directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERString.java
Date Wed, 12 Oct 2005 21:23:53 GMT
Author: elecharny
Date: Wed Oct 12 14:23:48 2005
New Revision: 315052

URL: http://svn.apache.org/viewcvs?rev=315052&view=rev
Log:
Fixed DIR-SNICKERS112.


Modified:
    directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERString.java

Modified: directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERString.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERString.java?rev=315052&r1=315051&r2=315052&view=diff
==============================================================================
--- directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERString.java (original)
+++ directory/asn1/trunk/der/src/java/org/apache/asn1/der/DERString.java Wed Oct 12 14:23:48
2005
@@ -17,6 +17,8 @@
 
 package org.apache.asn1.der;
 
+import java.io.UnsupportedEncodingException;
+
 /**
  * Interface for DER string objects.
  */
@@ -46,14 +48,14 @@
      */
     protected static String byteArrayToString( byte[] bytes )
     {
-        char[] characters = new char[ bytes.length ];
-
-        for ( int ii = 0; ii < characters.length; ii++ )
+        try
+        {
+            return new String( bytes, "UTF-8" );
+        }
+        catch ( UnsupportedEncodingException uee )
         {
-            characters[ ii ] = (char)( bytes[ ii ] & 0xff );
+            return "";
         }
-        
-        return new String( characters );
     }
     
     /**
@@ -63,15 +65,14 @@
      */
     protected static byte[] stringToByteArray( String string )
     {
-        char[] characters = string.toCharArray();
-        byte[] bytes = new byte[ characters.length ];
-
-        for ( int ii = 0; ii < characters.length; ii++ )
+        try
         {
-            bytes[ ii ] = (byte)characters[ ii ];
+            return string.getBytes( "UTF-8" );
+        }
+        catch ( UnsupportedEncodingException uee )
+        {
+            return new byte[]{};
         }
-
-        return bytes; 
     }
 }
 



Mime
View raw message