directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tomi Keinonen (JIRA)" <>
Subject [jira] Created: (DIRSNICKERS-112) DERUTF8String does not read and write UTF-8
Date Wed, 12 Oct 2005 13:44:05 GMT
DERUTF8String does not read and write UTF-8 

         Key: DIRSNICKERS-112
     Project: Directory ASN1
        Type: Bug
  Components: BER Runtime  
    Versions: 0.3.0    
    Reporter: Tomi Keinonen
 Assigned to: Alex Karasulu 

DERUTF8String class does not serialize Strings to byte arrays correctly. Also byte arrays
seem to be deserialized to Strings incorrectly.

For example character 'รถ' (U+00F6 Latin Small Letter O With Diaeresis) which should be serialized
to 0xC3B6 seems to be serialized to 0xF6. DERUTF8String uses only one byte for each char.
This means only ASCII characters work correctly. Each character which requires more than one
byte causes invalid byte output.

Class DERUTF8String seems to use incorrectly class DERString:

    protected static byte[] stringToByteArray( String string )
        char[] characters = string.toCharArray();
        byte[] bytes = new byte[ characters.length ];

        for ( int ii = 0; ii < characters.length; ii++ )
            bytes[ ii ] = (byte)characters[ ii ];

        return bytes;

This method converts parameter first to char array. Chars are UTF-16 and cannot be casted
to byte directly.  

Conversion should be done using method getBytes with parameter "UTF-8" of class String. 

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message