CharsetNames.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.apache.commons.compress.utils;

  18. import java.nio.charset.StandardCharsets;

  19. /**
  20.  * Character encoding names required of every implementation of the Java platform.
  21.  *
  22.  * From the Java documentation <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>:
  23.  * <p>
  24.  * <cite>Every implementation of the Java platform is required to support the following character encodings. Consult the release documentation for your
  25.  * implementation to see if any other encodings are supported. Consult the release documentation for your implementation to see if any other encodings are
  26.  * supported. </cite>
  27.  * </p>
  28.  *
  29.  * <dl>
  30.  * <dt>{@code US-ASCII}</dt>
  31.  * <dd>Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set.</dd>
  32.  * <dt>{@code ISO-8859-1}</dt>
  33.  * <dd>ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.</dd>
  34.  * <dt>{@code UTF-8}</dt>
  35.  * <dd>Eight-bit Unicode Transformation Format.</dd>
  36.  * <dt>{@code UTF-16BE}</dt>
  37.  * <dd>Sixteen-bit Unicode Transformation Format, big-endian byte order.</dd>
  38.  * <dt>{@code UTF-16LE}</dt>
  39.  * <dd>Sixteen-bit Unicode Transformation Format, little-endian byte order.</dd>
  40.  * <dt>{@code UTF-16}</dt>
  41.  * <dd>Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either order accepted on input, big-endian used
  42.  * on output.)</dd>
  43.  * </dl>
  44.  *
  45.  * <p>
  46.  * This perhaps would best belong in the [lang] project. Even if a similar interface is defined in [lang], it is not foreseen that [compress] would be made to
  47.  * depend on [lang].
  48.  * </p>
  49.  *
  50.  * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
  51.  * @since 1.4
  52.  * @deprecated Use {@link StandardCharsets}.
  53.  */
  54. @Deprecated
  55. public class CharsetNames {
  56.     /**
  57.      * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
  58.      * <p>
  59.      * Every implementation of the Java platform is required to support this character encoding.
  60.      * </p>
  61.      *
  62.      * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
  63.      */
  64.     public static final String ISO_8859_1 = StandardCharsets.ISO_8859_1.name();

  65.     /**
  66.      * <p>
  67.      * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set.
  68.      * </p>
  69.      * <p>
  70.      * Every implementation of the Java platform is required to support this character encoding.
  71.      * </p>
  72.      *
  73.      * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
  74.      */
  75.     public static final String US_ASCII = StandardCharsets.US_ASCII.name();

  76.     /**
  77.      * <p>
  78.      * Sixteen-bit Unicode Transformation Format, The byte order specified by a mandatory initial byte-order mark (either order accepted on input, big-endian
  79.      * used on output)
  80.      * </p>
  81.      * <p>
  82.      * Every implementation of the Java platform is required to support this character encoding.
  83.      * </p>
  84.      *
  85.      * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
  86.      */
  87.     public static final String UTF_16 = StandardCharsets.UTF_16.name();

  88.     /**
  89.      * <p>
  90.      * Sixteen-bit Unicode Transformation Format, big-endian byte order.
  91.      * </p>
  92.      * <p>
  93.      * Every implementation of the Java platform is required to support this character encoding.
  94.      * </p>
  95.      *
  96.      * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
  97.      */
  98.     public static final String UTF_16BE = StandardCharsets.UTF_16BE.name();

  99.     /**
  100.      * <p>
  101.      * Sixteen-bit Unicode Transformation Format, little-endian byte order.
  102.      * </p>
  103.      * <p>
  104.      * Every implementation of the Java platform is required to support this character encoding.
  105.      * </p>
  106.      *
  107.      * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
  108.      */
  109.     public static final String UTF_16LE = StandardCharsets.UTF_16LE.name();

  110.     /**
  111.      * <p>
  112.      * Eight-bit Unicode Transformation Format.
  113.      * </p>
  114.      * <p>
  115.      * Every implementation of the Java platform is required to support this character encoding.
  116.      * </p>
  117.      *
  118.      * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
  119.      */
  120.     public static final String UTF_8 = StandardCharsets.UTF_8.name();
  121. }