001    /*
002     * Copyright (C) 2007 Google Inc.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005     * in compliance with the License. You may obtain a copy of the License at
006     *
007     * http://www.apache.org/licenses/LICENSE-2.0
008     *
009     * Unless required by applicable law or agreed to in writing, software distributed under the
010     * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
011     * express or implied. See the License for the specific language governing permissions and
012     * limitations under the License.
013     */
014    
015    package com.google.common.base;
016    
017    import java.nio.charset.Charset;
018    
019    /**
020     * Contains constant definitions for the six standard {@link Charset} instances, which are
021     * guaranteed to be supported by all Java platform implementations.
022     *
023     * @author Mike Bostock
024     * @since 1
025     */
026    public final class Charsets {
027      private Charsets() {}
028    
029      /**
030       * US-ASCII: seven-bit ASCII, a.k.a. ISO646-US, a.k.a the Basic Latin block of the Unicode
031       * character set.
032       */
033      public static final Charset US_ASCII = Charset.forName("US-ASCII");
034    
035      /**
036       * ISO-8859-1. ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
037       */
038      public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
039    
040      /**
041       * UTF-8: eight-bit UCS Transformation Format.
042       */
043      public static final Charset UTF_8 = Charset.forName("UTF-8");
044    
045      /**
046       * UTF-16BE: sixteen-bit UCS Transformation Format, big-endian byte order.
047       */
048      public static final Charset UTF_16BE = Charset.forName("UTF-16BE");
049    
050      /**
051       * UTF-16LE: sixteen-bit UCS Transformation Format, little-endian byte order.
052       */
053      public static final Charset UTF_16LE = Charset.forName("UTF-16LE");
054    
055      /**
056       * UTF-16: sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order
057       * mark.
058       */
059      public static final Charset UTF_16 = Charset.forName("UTF-16");
060    
061      /*
062       * Please do not add new Charset references to this class, unless those character encodings are
063       * part of the set required to be supported by all Java platform implementations! Any Charsets
064       * initialized here may cause unexpected delays when this class is loaded. See the Charset
065       * Javadocs for the list of built-in character encodings.
066       */
067    }