Name: auR10023 Date: 03/14/2003
java.nio.charset.Charset.aliases() returns non empty alias sets for:
UTF-8, UTF-16BE, UTF-16LE, UTF-16 but according to the IANA Charset Registry
these charsets have no aliases.
Here is the example:
-------test.java---------
import java.nio.charset.*;
public class test {
public static void main (String [] args) {
Charset c = null;
String [] chrs = { "UTF-8", "UTF-16BE", "UTF-16LE", "UTF-16"};
for (int i = 0; i < chrs.length; i++) {
try {
c = Charset.forName(chrs[i]);
if (c.aliases().size() > 0) {
System.out.println("Charset " + chrs[i] +
" has non empty set of aliases");
}
} catch(IllegalCharsetNameException e) {
System.out.println("Unexpected " + e);
} catch (UnsupportedCharsetException e) {
System.out.println("Unexpected " + e);
}
}
}
}
Here is the result
#java -version
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b16)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b16, mixed mode)
#java test
Charset UTF-8 has non empty set of aliases
Charset UTF-16BE has non empty set of aliases
Charset UTF-16LE has non empty set of aliases
Charset UTF-16 has non empty set of aliases
======================================================================