Direct access to ICU charsets in Java?

Description

Currently, as far as I can tell, due to the protected or private status of the constructors for all the CharsetICU implementations, the only way to get an actual instance of one of the ICU charsets is to use the static CharsetICU.charsetForName(String name) method. Doing this works, but appears to involve a fairly convoluted process of calls back and forth between CharsetProviderICU, and at least two calls into (are they deprecated?) internal functions to fetch the names and aliases of the charsets from those processed text files. After all that, this data (aliases, for instance), if we are using the CharsetICU implementation anyway, isn't actually used for anything, even by the extended java.nio.charset.Charset, that I can find. Then finally the actual charset is instantiated wtih reflection, which while a small difference, takes longer than the new operator, no?

May I suggest that it's appropriate to have some public class analogous to the java.nio.charset.StandardCharsets, to allow direct, programmatic access to an instance of a given charset? Something like this (UnicodeCharsets.java):

Assignee

Yoshito Umaoka

Reporter

Joshua Chambers

Components

Labels

None

Reviewer

None

Priority

minor

Time Needed

None

Fix versions

Configure