CharsetNames.java

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

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

  20. import java.nio.charset.StandardCharsets;

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

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

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

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

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

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

  123.     /**
  124.      * Constructs a new instance.
  125.      */
  126.     public CharsetNames() {
  127.         // empty
  128.     }
  129. }