View Javadoc
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  
18  package org.apache.commons.compress.utils;
19  
20  import java.nio.charset.StandardCharsets;
21  
22  /**
23   * Character encoding names required of every implementation of the Java platform.
24   *
25   * From the Java documentation <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>:
26   * <p>
27   * <cite>Every implementation of the Java platform is required to support the following character encodings. Consult the release documentation for your
28   * implementation to see if any other encodings are supported. Consult the release documentation for your implementation to see if any other encodings are
29   * supported. </cite>
30   * </p>
31   *
32   * <dl>
33   * <dt>{@code US-ASCII}</dt>
34   * <dd>Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set.</dd>
35   * <dt>{@code ISO-8859-1}</dt>
36   * <dd>ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.</dd>
37   * <dt>{@code UTF-8}</dt>
38   * <dd>Eight-bit Unicode Transformation Format.</dd>
39   * <dt>{@code UTF-16BE}</dt>
40   * <dd>Sixteen-bit Unicode Transformation Format, big-endian byte order.</dd>
41   * <dt>{@code UTF-16LE}</dt>
42   * <dd>Sixteen-bit Unicode Transformation Format, little-endian byte order.</dd>
43   * <dt>{@code UTF-16}</dt>
44   * <dd>Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either order accepted on input, big-endian used
45   * on output.)</dd>
46   * </dl>
47   *
48   * <p>
49   * 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
50   * depend on [lang].
51   * </p>
52   *
53   * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
54   * @since 1.4
55   * @deprecated Use {@link StandardCharsets}.
56   */
57  @Deprecated
58  public class CharsetNames {
59      /**
60       * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
61       * <p>
62       * Every implementation of the Java platform is required to support this character encoding.
63       * </p>
64       *
65       * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
66       */
67      public static final String ISO_8859_1 = StandardCharsets.ISO_8859_1.name();
68  
69      /**
70       * <p>
71       * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set.
72       * </p>
73       * <p>
74       * Every implementation of the Java platform is required to support this character encoding.
75       * </p>
76       *
77       * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
78       */
79      public static final String US_ASCII = StandardCharsets.US_ASCII.name();
80  
81      /**
82       * <p>
83       * Sixteen-bit Unicode Transformation Format, The byte order specified by a mandatory initial byte-order mark (either order accepted on input, big-endian
84       * used on output)
85       * </p>
86       * <p>
87       * Every implementation of the Java platform is required to support this character encoding.
88       * </p>
89       *
90       * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
91       */
92      public static final String UTF_16 = StandardCharsets.UTF_16.name();
93  
94      /**
95       * <p>
96       * Sixteen-bit Unicode Transformation Format, big-endian byte order.
97       * </p>
98       * <p>
99       * Every implementation of the Java platform is required to support this character encoding.
100      * </p>
101      *
102      * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
103      */
104     public static final String UTF_16BE = StandardCharsets.UTF_16BE.name();
105 
106     /**
107      * <p>
108      * Sixteen-bit Unicode Transformation Format, little-endian byte order.
109      * </p>
110      * <p>
111      * Every implementation of the Java platform is required to support this character encoding.
112      * </p>
113      *
114      * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
115      */
116     public static final String UTF_16LE = StandardCharsets.UTF_16LE.name();
117 
118     /**
119      * <p>
120      * Eight-bit Unicode Transformation Format.
121      * </p>
122      * <p>
123      * Every implementation of the Java platform is required to support this character encoding.
124      * </p>
125      *
126      * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
127      */
128     public static final String UTF_8 = StandardCharsets.UTF_8.name();
129 }