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.codec; 019 020import java.nio.charset.Charset; 021 022/** 023 * Character encoding names required of every implementation of the Java platform. 024 * 025 * From the Java documentation for {@link Charset}: 026 * <p> 027 * <cite>Every implementation of the Java platform is required to support the following character encodings. Consult the 028 * release documentation for your implementation to see if any other encodings are supported. Consult the release 029 * documentation for your implementation to see if any other encodings are supported.</cite> 030 * </p> 031 * 032 * <ul> 033 * <li>{@code US-ASCII}<p> 034 * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set.</p></li> 035 * <li>{@code ISO-8859-1}<p> 036 * ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.</p></li> 037 * <li>{@code UTF-8}<p> 038 * Eight-bit Unicode Transformation Format.</p></li> 039 * <li>{@code UTF-16BE}<p> 040 * Sixteen-bit Unicode Transformation Format, big-endian byte order.</p></li> 041 * <li>{@code UTF-16LE}<p> 042 * Sixteen-bit Unicode Transformation Format, little-endian byte order.</p></li> 043 * <li>{@code UTF-16}<p> 044 * Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either order 045 * accepted on input, big-endian used on output.)</p></li> 046 * </ul> 047 * 048 * This perhaps would best belong in the [lang] project. Even if a similar interface is defined in [lang], it is not 049 * foreseen that [codec] would be made to depend on [lang]. 050 * 051 * <p> 052 * This class is immutable and thread-safe. 053 * </p> 054 * 055 * @see Charset 056 * @since 1.4 057 */ 058public class CharEncoding { 059 060 /** 061 * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1. 062 * <p> 063 * Every implementation of the Java platform is required to support this character encoding. 064 * </p> 065 * 066 * @see Charset 067 */ 068 public static final String ISO_8859_1 = "ISO-8859-1"; 069 070 /** 071 * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set. 072 * <p> 073 * Every implementation of the Java platform is required to support this character encoding. 074 * </p> 075 * 076 * @see Charset 077 */ 078 public static final String US_ASCII = "US-ASCII"; 079 080 /** 081 * Sixteen-bit Unicode Transformation Format, The byte order specified by a mandatory initial byte-order mark 082 * (either order accepted on input, big-endian used on output) 083 * <p> 084 * Every implementation of the Java platform is required to support this character encoding. 085 * </p> 086 * 087 * @see Charset 088 */ 089 public static final String UTF_16 = "UTF-16"; 090 091 /** 092 * Sixteen-bit Unicode Transformation Format, big-endian byte order. 093 * <p> 094 * Every implementation of the Java platform is required to support this character encoding. 095 * </p> 096 * 097 * @see Charset 098 */ 099 public static final String UTF_16BE = "UTF-16BE"; 100 101 /** 102 * Sixteen-bit Unicode Transformation Format, little-endian byte order. 103 * <p> 104 * Every implementation of the Java platform is required to support this character encoding. 105 * </p> 106 * 107 * @see Charset 108 */ 109 public static final String UTF_16LE = "UTF-16LE"; 110 111 /** 112 * Eight-bit Unicode Transformation Format. 113 * <p> 114 * Every implementation of the Java platform is required to support this character encoding. 115 * </p> 116 * 117 * @see Charset 118 */ 119 public static final String UTF_8 = "UTF-8"; 120}