javadocs say 'All other characters are converted into the 3-character string
%xy, where xy is the two-digit hexadecimal representation of the lower
8-bits of the character.'
Problem was seen trying to round trip Arabic text on a Sol8 system with a
default LANG of 'ar' (8859-6) through UTF-8 to URLEncoded and then all the
way back. The URLEncode decode was mangling the encoded text due to the
interaction with the non-english default charset.
But the code is:
OutputStreamWriter writer = new OutputStreamWriter(buf);
which uses the default encoding of the system property file.encoding to do
the encoding. If the char needs encoding, a sequence of bytes is written to
the outputstream rather than just the low 8 bits. The use of the writer is also unnecessary. See suggested fix for alternate code without the writer.
Will be filing the related bug in URLDecoder.decode() for related problem.
Seen in 1.2.2 and in 1.3.
%xy, where xy is the two-digit hexadecimal representation of the lower
8-bits of the character.'
Problem was seen trying to round trip Arabic text on a Sol8 system with a
default LANG of 'ar' (8859-6) through UTF-8 to URLEncoded and then all the
way back. The URLEncode decode was mangling the encoded text due to the
interaction with the non-english default charset.
But the code is:
OutputStreamWriter writer = new OutputStreamWriter(buf);
which uses the default encoding of the system property file.encoding to do
the encoding. If the char needs encoding, a sequence of bytes is written to
the outputstream rather than just the low 8 bits. The use of the writer is also unnecessary. See suggested fix for alternate code without the writer.
Will be filing the related bug in URLDecoder.decode() for related problem.
Seen in 1.2.2 and in 1.3.
- duplicates
-
JDK-4257115 URLEncoder and URLDecoder should support target character sets
- Resolved
- relates to
-
JDK-4488606 URLDecoder.decode() should not do charset conversion
- Closed