001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *   http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.compress.utils;
019
020import java.nio.charset.StandardCharsets;
021
022/**
023 * Character encoding names required of every implementation of the Java platform.
024 *
025 * From the Java documentation <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>:
026 * <p>
027 * <cite>Every implementation of the Java platform is required to support the following character encodings. Consult the release documentation for your
028 * implementation to see if any other encodings are supported. Consult the release documentation for your implementation to see if any other encodings are
029 * supported. </cite>
030 * </p>
031 *
032 * <dl>
033 * <dt>{@code US-ASCII}</dt>
034 * <dd>Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set.</dd>
035 * <dt>{@code ISO-8859-1}</dt>
036 * <dd>ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.</dd>
037 * <dt>{@code UTF-8}</dt>
038 * <dd>Eight-bit Unicode Transformation Format.</dd>
039 * <dt>{@code UTF-16BE}</dt>
040 * <dd>Sixteen-bit Unicode Transformation Format, big-endian byte order.</dd>
041 * <dt>{@code UTF-16LE}</dt>
042 * <dd>Sixteen-bit Unicode Transformation Format, little-endian byte order.</dd>
043 * <dt>{@code UTF-16}</dt>
044 * <dd>Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either order accepted on input, big-endian used
045 * on output.)</dd>
046 * </dl>
047 *
048 * <p>
049 * 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
050 * depend on [lang].
051 * </p>
052 *
053 * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
054 * @since 1.4
055 */
056public class CharsetNames {
057    /**
058     * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
059     * <p>
060     * Every implementation of the Java platform is required to support this character encoding.
061     * </p>
062     *
063     * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
064     */
065    public static final String ISO_8859_1 = StandardCharsets.ISO_8859_1.name();
066
067    /**
068     * <p>
069     * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set.
070     * </p>
071     * <p>
072     * Every implementation of the Java platform is required to support this character encoding.
073     * </p>
074     *
075     * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
076     */
077    public static final String US_ASCII = StandardCharsets.US_ASCII.name();
078
079    /**
080     * <p>
081     * Sixteen-bit Unicode Transformation Format, The byte order specified by a mandatory initial byte-order mark (either order accepted on input, big-endian
082     * used on output)
083     * </p>
084     * <p>
085     * Every implementation of the Java platform is required to support this character encoding.
086     * </p>
087     *
088     * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
089     */
090    public static final String UTF_16 = StandardCharsets.UTF_16.name();
091
092    /**
093     * <p>
094     * Sixteen-bit Unicode Transformation Format, big-endian byte order.
095     * </p>
096     * <p>
097     * Every implementation of the Java platform is required to support this character encoding.
098     * </p>
099     *
100     * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
101     */
102    public static final String UTF_16BE = StandardCharsets.UTF_16BE.name();
103
104    /**
105     * <p>
106     * Sixteen-bit Unicode Transformation Format, little-endian byte order.
107     * </p>
108     * <p>
109     * Every implementation of the Java platform is required to support this character encoding.
110     * </p>
111     *
112     * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
113     */
114    public static final String UTF_16LE = StandardCharsets.UTF_16LE.name();
115
116    /**
117     * <p>
118     * Eight-bit Unicode Transformation Format.
119     * </p>
120     * <p>
121     * Every implementation of the Java platform is required to support this character encoding.
122     * </p>
123     *
124     * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
125     */
126    public static final String UTF_8 = StandardCharsets.UTF_8.name();
127}