commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 38288] - [codec] encode/decode fails for "ˇ"
Date Mon, 16 Jan 2006 18:57:42 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38288>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38288


olegk@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Additional Comments From olegk@apache.org  2006-01-16 19:57 -------
(In reply to comment #0)
> If you encode the character "ˇ" - inverted exclamation mark - it becomes 
> %C2%A1, which is incorrect it should be %A1. 

This observation is not correct. '%C2%A1' is perfectly fine if the UTF-8 is used.

If you decode "%A1" it should 
> give you "ˇ"  and instead it give ? - which means it's producing a character 
> it can't display, possibly a binary char. If you decode "%C2%A1" you do 
> get "ˇ", but "%A1" is the conversion for "ˇ" and not "%C2%A1".

Apparently you are using (assuming) different charsets when encoding / decoding
content in your application.

These test cases work for me

    public void testInvertedExclamationMarkUTF8() throws Exception {
        String invertedExclMark = new String(new char[] { 0xa1 }); 

        URLCodec urlCodec = new URLCodec();
        String encoded = urlCodec.encode(invertedExclMark, "UTF-8");
        assertEquals("%C2%A1", encoded);
        
        String decoded = urlCodec.decode(encoded, "UTF-8");
        assertEquals(invertedExclMark, decoded);
    }

    public void testInvertedExclamationMarkISO() throws Exception {
        String invertedExclMark = new String(new char[] { 0xa1 }); 

        URLCodec urlCodec = new URLCodec();
        String encoded = urlCodec.encode(invertedExclMark, "ISO-8859-1");
        assertEquals("%A1", encoded);
        
        String decoded = urlCodec.decode(encoded, "ISO-8859-1");
        assertEquals(invertedExclMark, decoded);
    }

    public void testInvertedExclamationMarkDefault() throws Exception {
        String invertedExclMark = new String(new char[] { 0xa1 }); 

        URLCodec urlCodec = new URLCodec();
        String encoded = urlCodec.encode(invertedExclMark);
        String decoded = urlCodec.decode(encoded);
        assertEquals(invertedExclMark, decoded);
    }

So, as far as I am concerned the URLCodec works as advertised. 

Oleg

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message