java.io.PrintStream is normally used for printing out data that is
intended to be human readable. For this reason, it uses the platform
default encoding when converting characters to bytes.
However, PrintStream has also been used for outputing protocol data
such as HTTP headers. Some of the URLStreamHandlers in java.net
actually return a PrintStream to the application so the application
can send its own data on to the stream.
This causes a problem, in that all internet protocols must transmit
their data in a specific encoding (ASCII) rather than the default
encoding supported by the platform. This problem is only apparent
when the default encoding is set to some derivative of EBCDIC
(such as Cp037), because EBCDIC maps the normal alpha-numeric
characters to different values from ASCII.
The desired solution is to add a constructor to java.io.PrintStream
where the encoding can be specified by the caller. Protocol code
that wants to guarantee a specific encoding such as ISO8859_1 will
use this new constructor.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
intended to be human readable. For this reason, it uses the platform
default encoding when converting characters to bytes.
However, PrintStream has also been used for outputing protocol data
such as HTTP headers. Some of the URLStreamHandlers in java.net
actually return a PrintStream to the application so the application
can send its own data on to the stream.
This causes a problem, in that all internet protocols must transmit
their data in a specific encoding (ASCII) rather than the default
encoding supported by the platform. This problem is only apparent
when the default encoding is set to some derivative of EBCDIC
(such as Cp037), because EBCDIC maps the normal alpha-numeric
characters to different values from ASCII.
The desired solution is to add a constructor to java.io.PrintStream
where the encoding can be specified by the caller. Protocol code
that wants to guarantee a specific encoding such as ISO8859_1 will
use this new constructor.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- duplicates
-
JDK-4285162 Provide encoding in constructor of Printwriter
-
- Closed
-
- relates to
-
JDK-4311523 URL.openConnection() works wrong for Cp037
-
- Resolved
-