001/*
002 * Copyright (C) 2007 The Guava Authors
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 License
010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011 * or implied. See the License for the specific language governing permissions and limitations under
012 * the License.
013 */
014
015package com.google.common.base;
016
017import com.google.common.annotations.GwtCompatible;
018import com.google.common.annotations.GwtIncompatible;
019import com.google.common.annotations.J2ktIncompatible;
020import java.nio.charset.Charset;
021import java.nio.charset.StandardCharsets;
022
023/**
024 * Contains constant definitions for the six standard {@link Charset} instances, which are
025 * guaranteed to be supported by all Java platform implementations.
026 *
027 * <p>Assuming you're free to choose, note that <b>{@link #UTF_8} is widely preferred</b>.
028 *
029 * <p>See the Guava User Guide article on <a
030 * href="https://github.com/google/guava/wiki/StringsExplained#charsets">{@code Charsets}</a>.
031 *
032 * @author Mike Bostock
033 * @since 1.0
034 */
035@GwtCompatible(emulated = true)
036@ElementTypesAreNonnullByDefault
037public final class Charsets {
038  private Charsets() {}
039
040  /**
041   * US-ASCII: seven-bit ASCII, the Basic Latin block of the Unicode character set (ISO646-US).
042   *
043   * <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
044   * {@link StandardCharsets#US_ASCII} instead.
045   *
046   */
047  @J2ktIncompatible
048  @GwtIncompatible // Charset not supported by GWT
049  public static final Charset US_ASCII = StandardCharsets.US_ASCII;
050
051  /**
052   * ISO-8859-1: ISO Latin Alphabet Number 1 (ISO-LATIN-1).
053   *
054   * <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
055   * {@link StandardCharsets#ISO_8859_1} instead.
056   *
057   */
058  public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
059
060  /**
061   * UTF-8: eight-bit UCS Transformation Format.
062   *
063   * <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
064   * {@link StandardCharsets#UTF_8} instead.
065   *
066   */
067  public static final Charset UTF_8 = StandardCharsets.UTF_8;
068
069  /**
070   * UTF-16BE: sixteen-bit UCS Transformation Format, big-endian byte order.
071   *
072   * <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
073   * {@link StandardCharsets#UTF_16BE} instead.
074   *
075   */
076  @J2ktIncompatible
077  @GwtIncompatible // Charset not supported by GWT
078  public static final Charset UTF_16BE = StandardCharsets.UTF_16BE;
079
080  /**
081   * UTF-16LE: sixteen-bit UCS Transformation Format, little-endian byte order.
082   *
083   * <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
084   * {@link StandardCharsets#UTF_16LE} instead.
085   *
086   */
087  @J2ktIncompatible
088  @GwtIncompatible // Charset not supported by GWT
089  public static final Charset UTF_16LE = StandardCharsets.UTF_16LE;
090
091  /**
092   * UTF-16: sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order
093   * mark.
094   *
095   * <p><b>Note:</b> this constant is now unnecessary and should be treated as deprecated; use
096   * {@link StandardCharsets#UTF_16} instead.
097   *
098   */
099  @J2ktIncompatible
100  @GwtIncompatible // Charset not supported by GWT
101  public static final Charset UTF_16 = StandardCharsets.UTF_16;
102
103  /*
104   * Please do not add new Charset references to this class, unless those character encodings are
105   * part of the set required to be supported by all Java platform implementations! Any Charsets
106   * initialized here may cause unexpected delays when this class is loaded. See the Charset
107   * Javadocs for the list of built-in character encodings.
108   */
109}