Class Encoding

  • All Implemented Interfaces:
    java.lang.Comparable<java.nio.charset.Charset>

    public abstract class Encoding
    extends java.nio.charset.Charset
    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 CharsetProvider and, 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. Encoding.UTF_8 and Encoding.WINDOWS_1252 respectively, should be used. However, when the application receives an encoding label from external input, the method forName() 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() should be used instead.

    Author:
    hsivonen
    • Field Detail

      • BIG5

        public static final Encoding BIG5
        The big5 encoding.
      • EUC_JP

        public static final Encoding EUC_JP
        The euc-jp encoding.
      • EUC_KR

        public static final Encoding EUC_KR
        The euc-kr encoding.
      • GB18030

        public static final Encoding GB18030
        The gb18030 encoding.
      • GBK

        public static final Encoding GBK
        The gbk encoding.
      • IBM866

        public static final Encoding IBM866
        The ibm866 encoding.
      • ISO_2022_JP

        public static final Encoding ISO_2022_JP
        The iso-2022-jp encoding.
      • ISO_8859_10

        public static final Encoding ISO_8859_10
        The iso-8859-10 encoding.
      • ISO_8859_13

        public static final Encoding ISO_8859_13
        The iso-8859-13 encoding.
      • ISO_8859_14

        public static final Encoding ISO_8859_14
        The iso-8859-14 encoding.
      • ISO_8859_15

        public static final Encoding ISO_8859_15
        The iso-8859-15 encoding.
      • ISO_8859_16

        public static final Encoding ISO_8859_16
        The iso-8859-16 encoding.
      • ISO_8859_2

        public static final Encoding ISO_8859_2
        The iso-8859-2 encoding.
      • ISO_8859_3

        public static final Encoding ISO_8859_3
        The iso-8859-3 encoding.
      • ISO_8859_4

        public static final Encoding ISO_8859_4
        The iso-8859-4 encoding.
      • ISO_8859_5

        public static final Encoding ISO_8859_5
        The iso-8859-5 encoding.
      • ISO_8859_6

        public static final Encoding ISO_8859_6
        The iso-8859-6 encoding.
      • ISO_8859_7

        public static final Encoding ISO_8859_7
        The iso-8859-7 encoding.
      • ISO_8859_8

        public static final Encoding ISO_8859_8
        The iso-8859-8 encoding.
      • ISO_8859_8_I

        public static final Encoding ISO_8859_8_I
        The iso-8859-8-i encoding.
      • KOI8_R

        public static final Encoding KOI8_R
        The koi8-r encoding.
      • KOI8_U

        public static final Encoding KOI8_U
        The koi8-u encoding.
      • MACINTOSH

        public static final Encoding MACINTOSH
        The macintosh encoding.
      • REPLACEMENT

        public static final Encoding REPLACEMENT
        The replacement encoding.
      • SHIFT_JIS

        public static final Encoding SHIFT_JIS
        The shift_jis encoding.
      • UTF_16BE

        public static final Encoding UTF_16BE
        The utf-16be encoding.
      • UTF_16LE

        public static final Encoding UTF_16LE
        The utf-16le encoding.
      • UTF_8

        public static final Encoding UTF_8
        The utf-8 encoding.
      • WINDOWS_1250

        public static final Encoding WINDOWS_1250
        The windows-1250 encoding.
      • WINDOWS_1251

        public static final Encoding WINDOWS_1251
        The windows-1251 encoding.
      • WINDOWS_1252

        public static final Encoding WINDOWS_1252
        The windows-1252 encoding.
      • WINDOWS_1253

        public static final Encoding WINDOWS_1253
        The windows-1253 encoding.
      • WINDOWS_1254

        public static final Encoding WINDOWS_1254
        The windows-1254 encoding.
      • WINDOWS_1255

        public static final Encoding WINDOWS_1255
        The windows-1255 encoding.
      • WINDOWS_1256

        public static final Encoding WINDOWS_1256
        The windows-1256 encoding.
      • WINDOWS_1257

        public static final Encoding WINDOWS_1257
        The windows-1257 encoding.
      • WINDOWS_1258

        public static final Encoding WINDOWS_1258
        The windows-1258 encoding.
      • WINDOWS_874

        public static final Encoding WINDOWS_874
        The windows-874 encoding.
      • X_MAC_CYRILLIC

        public static final Encoding X_MAC_CYRILLIC
        The x-mac-cyrillic encoding.
      • X_USER_DEFINED

        public static final Encoding X_USER_DEFINED
        The x-user-defined encoding.
    • Constructor Detail

      • Encoding

        protected Encoding​(java.lang.String canonicalName,
                           java.lang.String[] aliases)
    • Method Detail

      • forName

        public static Encoding forName​(java.lang.String label)
      • forNameNoReplacement

        public static Encoding forNameNoReplacement​(java.lang.String label)
      • isSupported

        public static boolean isSupported​(java.lang.String label)
      • isSupportedNoReplacement

        public static boolean isSupportedNoReplacement​(java.lang.String label)
      • availableCharsets

        public static java.util.SortedMap<java.lang.String,​java.nio.charset.Charset> availableCharsets()
      • defaultCharset

        public static Encoding defaultCharset()
      • canEncode

        public boolean canEncode()
        Overrides:
        canEncode in class java.nio.charset.Charset
      • contains

        public boolean contains​(java.nio.charset.Charset cs)
        Specified by:
        contains in class java.nio.charset.Charset
      • newEncoder

        public java.nio.charset.CharsetEncoder newEncoder()
        Specified by:
        newEncoder in class java.nio.charset.Charset