JDK-4772857 : (cs) Need a standard way to get the default encoding
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.4.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_8
  • CPU: generic
  • Submitted: 2002-11-01
  • Updated: 2017-05-16
  • Resolved: 2003-09-26
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
5.0 tigerFixed
Related Reports
Relates :  
Description
The NIO APIs provide neither a way get the name of the default encoding
nor a way to get the default charset.  Please add a method to do this.
I suggest

	public static Charset Charset.default();


Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b22
14-06-2004

WORK AROUND Use the system property "file.encoding" mentioned in the java tutorial and in the javadoc for OutputStreamWriter in JDK 1.2.2. I note that this documentation has been removed in more recent JDKs, suggesting that it is not an officially supported mechanism. (By the way, rumor has it that the fact that this property is the default encoding is tested for in the java certification exams). Name: nl37777 Date: 11/01/2002 A better workaround is to use the code OutputStream out = new ByteArrayOutputStream(); String defaultIOEncoding = (new OutputStreamWriter(out)).getEncoding(); This will return the old java.io canonical name for the character encoding, which is not always the same as the java.nio canonical name, but is always supported as an alias of the corresponding java.nio charset. If the java.nio canonical name is desired, it can be obtained by String defaultNIOEncoding = Charset.forName(defaultIOEncoding).name(); See http://java.sun.com/j2se/1.4.1/docs/guide/intl/encoding.doc.html for both old and new names. ======================================================================
11-06-2004

EVALUATION A fine idea. -- ###@###.### 2002/11/13
11-10-0179