JDK-4075317 : URLEncoder.encode() method fails on non-ISO8859 character encodings.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.1.3
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1997-08-29
  • Updated: 1997-08-30
  • Resolved: 1997-08-30
Related Reports
Duplicate :  
Description
URLEncoder.encode() method uses the platform default character encoder to create a byte array to be URL encoded.  This fails when  the default character encoder is not ASCII compatible.

Comments
SUGGESTED FIX Change call to OutputStreamWriter as per example: public static String encode(String s) { int maxBytesPerChar = 10; ByteArrayOutputStream out = new ByteArrayOutputStream(s.length()); ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar); OutputStreamWriter writer = new OutputStreamWriter(buf,"ISO8859_1"); // method continues
11-06-2004

EVALUATION This is a duplicate of 4041072. benjamin.renaud@Eng 1997-08-29
29-08-1997