org.apache.logging.log4j.core.util
Class Charsets

java.lang.Object
  extended by org.apache.logging.log4j.core.util.Charsets

public final class Charsets
extends Object

Charset utilities. Contains the standard character sets guaranteed to be available on all implementations of the Java platform. Parts adapted from JDK 1.7 (in particular, the java.nio.charset.StandardCharsets class).

See Also:
Charset

Field Summary
static Charset ISO_8859_1
          ISO Latin Alphabet No.
static Charset US_ASCII
          Seven-bit ASCII.
static Charset UTF_16
          Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark.
static Charset UTF_16BE
          Sixteen-bit UCS Transformation Format, big-endian byte order.
static Charset UTF_16LE
          Sixteen-bit UCS Transformation Format, little-endian byte order.
static Charset UTF_8
          Eight-bit UCS Transformation Format.
 
Method Summary
static Charset getSupportedCharset(String charsetName)
          Returns a Charset, if possible the Charset for the specified charsetName, otherwise (if the specified charsetName is null or not supported) this method returns the platform default Charset.
static Charset getSupportedCharset(String charsetName, Charset defaultCharset)
          Returns a Charset, if possible the Charset for the specified charsetName, otherwise (if the specified charsetName is null or not supported) this method returns the platform default Charset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

US_ASCII

public static final Charset US_ASCII
Seven-bit ASCII. ISO646-US. The Basic Latin block of the Unicode character set.


ISO_8859_1

public static final Charset ISO_8859_1
ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.


UTF_8

public static final Charset UTF_8
Eight-bit UCS Transformation Format.


UTF_16BE

public static final Charset UTF_16BE
Sixteen-bit UCS Transformation Format, big-endian byte order.


UTF_16LE

public static final Charset UTF_16LE
Sixteen-bit UCS Transformation Format, little-endian byte order.


UTF_16

public static final Charset UTF_16
Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark.

Method Detail

getSupportedCharset

public static Charset getSupportedCharset(String charsetName)
Returns a Charset, if possible the Charset for the specified charsetName, otherwise (if the specified charsetName is null or not supported) this method returns the platform default Charset.

Parameters:
charsetName - name of the preferred charset or null
Returns:
a Charset, not null.

getSupportedCharset

public static Charset getSupportedCharset(String charsetName,
                                          Charset defaultCharset)
Returns a Charset, if possible the Charset for the specified charsetName, otherwise (if the specified charsetName is null or not supported) this method returns the platform default Charset.

Parameters:
charsetName - name of the preferred charset or null
defaultCharset - returned if charsetName is null or is not supported.
Returns:
a Charset, never null.


Copyright © 1999-2014 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.