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 34717] New: - URLCodec does not encode correctly with special characters in UTF-8 charset..
Date Mon, 02 May 2005 22:34:26 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=34717>.
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=34717

           Summary: URLCodec does not encode correctly with special
                    characters in UTF-8 charset..
           Product: Commons
           Version: 1.3 Final
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: major
          Priority: P2
         Component: Codec
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: sr_ezhil@yahoo.com


URLCodec does not encode correctly with special characters in UTF-8 charset.
For eg, for the following special char  ń

test case:
Run the following test program (java EncodeTest ń) see the output from
both URLCodec and java.net.URLEncoder.

--------------------------------------------------------------------------
import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.net.URLCodec;

public class EncodeTest
{
    //////////////////////////////////////////////////
    // STATIC VARIABLES
    //////////////////////////////////////////////////
    private static URLCodec myInstance = new URLCodec();

    //////////////////////////////////////////////////
    // STATIC PUBLIC METHODS
    //////////////////////////////////////////////////

    /**
     * Given a url, encode it
     */
    public static String encode(String s)
    {
        try
        {
            System.out.println("TEST "+myInstance.getDefaultCharset());//UTF-8

            String s1 =  myInstance.encode(s1);
            
            String s2 = java.net.URLEncoder.encode(s);
            

            System.out.println(s1);
            System.out.println(s2);
        }
        catch (Exception ee)
        {
            // No point to do anything here, as it does not seem
            // to be caught.  Best we can do is just return
            // the string passed in.
            System.out.println(ee);
        }
        return s;
    }

    public static String decode(String s)
    {
        try
        {
            s = myInstance.decode(s);
        }
        catch (DecoderException ee)
        {
            // No point to do anything here, as it does not seem
            // to be caught.  Best we can do is just return
            // the string passed in.
        }
        return s;
    }
    
    
    public static void main(String argv[])
    {
		EncodeTest et = new EncodeTest();
		et.encode(argv[0]);
    
    }
}
-------------------------------------------------------------------

-- 
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