directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DIRSTUDIO-802) confusion between ISO-8859-1 and UTF-8 in the encode/decode LDAP gui tool
Date Fri, 06 Apr 2012 07:50:30 GMT

    [ https://issues.apache.org/jira/browse/DIRSTUDIO-802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13248162#comment-13248162
] 

Emmanuel Lecharny commented on DIRSTUDIO-802:
---------------------------------------------

Here is what I get when I use this snippet of code :

    @Test
    public void testUtf8Base64() throws UnsupportedEncodingException
    {
        String name = new String( "herv\u00e9" ); // Hervé in Unicode
        byte[] utf8 = Strings.getBytesUtf8( name );
        
        System.out.println( Strings.dumpBytes( utf8 ) );
        
        String utf8Base64 = new String( Base64.encode( utf8 ) );
        
        System.out.println( "Herv\u00e9 utf-8 base 64 encoded : " + utf8Base64 );
        
        byte[] iso8859 = name.getBytes( "ISO-8859-1" );
        System.out.println( Strings.dumpBytes( iso8859 ) );

        String iso8859Base64 = new String( Base64.encode( iso8859 ) );
        
        System.out.println( "Herv\u00e9 ISO-8859-1 base 64 encoded : " + iso8859Base64 );
    }

produces :

0x68 0x65 0x72 0x76 0xC3 0xA9 
Hervé utf-8 base 64 encoded : aGVydsOp
0x68 0x65 0x72 0x76 0xE9 
Hervé ISO-8859-1 base 64 encoded : aGVyduk=

                
> confusion between ISO-8859-1 and UTF-8 in the encode/decode LDAP gui tool
> -------------------------------------------------------------------------
>
>                 Key: DIRSTUDIO-802
>                 URL: https://issues.apache.org/jira/browse/DIRSTUDIO-802
>             Project: Directory Studio
>          Issue Type: Bug
>    Affects Versions: 1.5.3
>         Environment: Windows XP pro
>            Reporter: julien2512
>            Priority: Minor
>              Labels: decode, encode, iso-8859-1, utf8
>         Attachments: encode-decode LDAP demo 1.PNG, encode-decode LDAP demo 2.PNG
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The encode/decode tool (from the LDAP menu) gives "aGVydsOp" for BASE-64 encoding from
the ISO-8859-1 string "hervé".
> while the website http://www.base64decode.org/   gives the same results from the same
string but in UTF-8.
> Also UTF-8 BASE 64 encoding of Apache Directory Studio match with ISO-8859-1 BASE64 encoding
of the previous website.
> The result from my own java code match with that website.
> I think there is a confusion between ISO-8859-1 and UTF-8 in the encode/decode LDAP gui
tool of Apache Directory Studio.
> It will be easy to fix.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message