Represents an
encoding
as defined in the
Encoding
Standard, provides access to each encoding defined in the Encoding
Standard via a static constant and provides the
"
get an
encoding" algorithm defined in the Encoding Standard.
This class inherits from
Charset to allow the Encoding
Standard-compliant encodings to be used in contexts that support
Charset
instances. However, by design, the Encoding
Standard-compliant encodings are not supplied via a
CharsetProviderand, therefore, are not available via and do not interfere with the static
methods provided by Charset
. (This class provides methods of
the same name to hide each static method of Charset
to help
avoid accidental calls to the static methods of the superclass when working
with Encoding Standard-compliant encodings.)
When an application needs to use a particular encoding, such as utf-8
or windows-1252, the corresponding constant, i.e.
#UTF_8 and
#WINDOWS_1252respectively, should be used. However, when the application receives an
encoding label from external input, the method
#forName(String) should be used to obtain the object representing the encoding
identified by the label. In contexts where labels that map to the
replacement
encoding should be treated as unknown, the method
#forNameNoReplacement(String) should be used instead.