JDK-4175635 : (cs) Default file encoding not specified
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: unknown
  • Submitted: 1998-09-22
  • Updated: 2015-08-28
  • Resolved: 2015-08-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0Fixed
Related Reports
Relates :  
Description
String.getBytes() relies on the default encoding, but
this encoding is not specified.   Of course, the encoding
depends on the platform and can't be the same worldwide.
However, we don't specify how the default file encoding
is set, when it is set, or how a developer can determine
its value.

Does the default file encoding depend on the file.encoding
System.property?  What methods use the default file encoding?
The  API specs don't say.

The file.encoding System property is not specified, or even 
mentioned in the API specs.  (See System.getProperties)

The default file encoding touches a number of areas:

* the -encoding flag of the javac compiler
* String.getBytes(String enc)
* String(byte[] byteArray, String enc)
* InputStreamReader.getEncoding()
* InputStreamReader( InputStream in, String enc)
* UnsupportedEndodingException

File encodings vary considerably around the world,
so this is significant in terms of internationalization.

Comments
closed as "fixed", as we now have java.nio.charset.Charset.defaultCharset() as the point for "default charset" with clear specification.
28-08-2015

EVALUATION A possible improvement/solution is to add the "implementation details" of how the "default charset" is being detected on our supported platforms at our guild/intl/encoding page.
07-12-2006

EVALUATION Looks like this should be specified. gilad.bracha@eng 1998-09-29 Name: nl37777 Date: 09/03/2004 The situation has improved somewhat in the years since this bug was filed: - The java.nio.charset.Charset class description now mentions that "Every instance of the Java virtual machine has a default charset, which may or may not be one of the standard charsets. The default charset is determined during virtual-machine startup and typically depends upon the locale and charset being used by the underlying operating system." - The same class also offers a method defaultCharset, which lets an application find out about the actual default encoding. - The String and InputStreamReader specifications refer to the Charset class multiple times. There are still some gaps though - for example, the javac documentation refers to "platform default converter" with no explanation what that is. The file.encoding is intentionally not documented in the platform specification. It's an implementation detail of Sun's JREs, and applications should not rely on it. See bug 4163515. ======================================================================
26-09-2004

WORK AROUND
26-09-2004

SUGGESTED FIX
26-09-2004

PUBLIC COMMENTS
26-09-2004