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 */ 56 public class CharsetNames { 57 /** 58 * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1. 59 * <p> 60 * Every implementation of the Java platform is required to support this character encoding. 61 * </p> 62 * 63 * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a> 64 */ 65 public static final String ISO_8859_1 = StandardCharsets.ISO_8859_1.name(); 66 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 /** 80 * <p> 81 * Sixteen-bit Unicode Transformation Format, The byte order specified by a mandatory initial byte-order mark (either order accepted on input, big-endian 82 * used on output) 83 * </p> 84 * <p> 85 * Every implementation of the Java platform is required to support this character encoding. 86 * </p> 87 * 88 * @see <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html">Standard charsets</a> 89 */ 90 public static final String UTF_16 = StandardCharsets.UTF_16.name(); 91 92 /** 93 * <p> 94 * Sixteen-bit Unicode Transformation Format, big-endian byte order. 95 * </p> 96 * <p> 97 * Every implementation of the Java platform is required to support this character encoding. 98 * </p> 99 * 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 }