https://issues.apache.org/bugzilla/show_bug.cgi?id=38115

Tetsuya Takatsuru <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #5 from Tetsuya Takatsuru <[email protected]> 
2011-09-16 22:01:43 UTC ---
org.apache.commons.codec.net.URLCodec#encode/decode is better than
java.net.URLEncoder/URLDecoder.

java.net.URLDecoder cannot decode correctly in this case:

===example
String s = "登録";

String commons_encoded = new URLCodec("MS932").encode(s);
System.out.println("Encoded by commons-codec: " + commons_encoded);
// outputs: Encoded by commons-codec: %93o%98%5E
// some CJK multi-byte encodings use ASCII area at second byte.
// IE and Firefox (and some other browsers) encodes like as this.

String java_encoded = URLEncoder.encode(s, "MS932");
System.out.println("Encoded by java.net.URLEncoder: " + java_encoded);
// outputs: Encoded by java.net.URLEncoder: %93%6F%98%5E

System.out.println(URLDecoder.decode(java_encoded, "MS932"));      //OK
System.out.println(URLDecoder.decode(commons_encoded, "MS932"));   //NG
System.out.println(new URLCodec("MS932").decode(java_encoded));    //OK
System.out.println(new URLCodec("MS932").decode(commons_encoded)); //OK
===end example

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to