JDK-8066570 : Highlight Charset aliases in encoding docs
  • Type: Enhancement
  • Component: docs
  • Affected Version: 12
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-12-03
  • Updated: 2019-09-19
  • Resolved: 2019-01-25
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.
JDK 11 JDK 12
11Fixed 12Fixed
Related Reports
Relates :  
Relates :  
Description
Background: 
After one customer upgraded from 5u17, garbled text occurred on their application where "UNICODE" was used. 
Then they found it was caused by the fix of JDK-6292322. 

The behavior of String#getBytes("UNICODE") was changed by the fix. 
before: return UTF-16 of Litle Endian with BOM 
after : return UTF-16 of Big Endian with BOM


This is an enhancement request that requires Sustaining resolution.

Exception is not raised when an invalid name "UNICODE" is used in 
java.lang.String#getBytes. However, "UNICODE" is not supported 
according to the page below:

http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html

The test case Test.java 

class Test{ 
  public static void main(String[] args) throws 
  java.io.UnsupportedEncodingException{ 
  System.out.println("Hello".getBytes("UNICODE")); 
  } 
} 
 
To reproduce: 
1. jdk8u25/bin/javac Test.java 
2. jdk8u25/bin/java Test 
 
Suggested Fix: 
  Does strict check on API unsupported parameters 
  Make noticeable announcement if incompatibility change is made 
Comments
Looks like JDK 8 docs were updated. The JDK 11 docs could do with the same addition and/or highlighting of testcase.
13-12-2018

Can I ask the docs team to pick this up ? Please include example code like that below in the JDK supported aliases document page[1] (maybe the JDK 8 one[2] also) $ cat DisplayCharsetAliases.java import java.nio.charset.*; class DisplayCharsetAliases { public static void main(String[] args) { System.out.println("Charset: --> Aliases"); System.out.println("====================="); for(Charset cs : Charset.availableCharsets().values()) { System.out.println(cs.name() + ": " + cs.aliases()); } } } [1] https://docs.oracle.com/javase/9/intl/supported-encodings.htm#JSINT-GUID-D29CF3AD-FC0B-465F-8897-C38C0395AB02 [2] https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html
12-12-2018

Anyone can determine aliases via the API provided : Charset c = Charset.forName("UNICODE"); System.out.println("UNICODE : " + c.aliases()); This behavioural change (adding "Unicode" as an alias) was done in 2005 via JDK-4454622. I don't believe this needs to remain open but I'll follow up with submitter.
13-09-2017

fair requirement -- to add all alias names into "supported encodings pages"
15-08-2015

"unicode" is the supported alias of charset "UTF-16". Try to print out Charset.forName("UNICODE");
05-12-2014