decode() has this section at the end of it:
// Undo conversion to external encoding
String result = sb.toString();
byte[] inputBytes = result.getBytes("8859_1");
return new String(inputBytes);
but URLEncoder.encode() OutputStreamWriter() uses the default constructor
so it does not specify what the charset used is, so it is not necessarily
have to be 8859_1. Since URLEncoder.encode() is 'supposedly' just taking
the low 8bits and encoding them, and this is just reversing that, then
this step is not needed. The end of this function should just be:
return sb.toString();
// Undo conversion to external encoding
String result = sb.toString();
byte[] inputBytes = result.getBytes("8859_1");
return new String(inputBytes);
but URLEncoder.encode() OutputStreamWriter() uses the default constructor
so it does not specify what the charset used is, so it is not necessarily
have to be 8859_1. Since URLEncoder.encode() is 'supposedly' just taking
the low 8bits and encoding them, and this is just reversing that, then
this step is not needed. The end of this function should just be:
return sb.toString();
- duplicates
-
JDK-4257115 URLEncoder and URLDecoder should support target character sets
- Resolved
- relates to
-
JDK-4488596 URLEncoder.encode() does not always take the low 8 bits of character
- Closed