Package com.globalmentor.io
Class Charsets
- java.lang.Object
-
- com.globalmentor.io.Charsets
-
public class Charsets extends java.lang.Object
Utilities for working with charsets.In most cases, rather that using the names provided here, consider using
Charset.name()
for one of the predefined charsets inStandardCharsets
.- Author:
- Garret Wilson
- See Also:
- IANA Charset Registry,
XML 1.0 Fourth Edition: Autodetection of Character Encodings (Non-Normative),
StandardCharsets
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ISO_8859_1_NAME
The canonical name of the ISO-8859-1 charset.static java.lang.String
US_ASCII_NAME
The canonical name of the US-ASCII charset.static java.lang.String
UTF_16_NAME
The canonical name of the general 16-bit UTF-16 charset (which requires an initial Byte Order Mark).static java.lang.String
UTF_16BE_NAME
The canonical name of the 16-bit UTF-16 big-endian charset.static java.lang.String
UTF_16LE_NAME
The canonical name of the 16-bit UTF-16 little-endian charset.static java.lang.String
UTF_32_NAME
The canonical name of the 32-bit UTF-32 charset.static java.lang.String
UTF_32BE_NAME
The canonical name of the 32-bit UTF-32 big-endian charset.static java.lang.String
UTF_32LE_NAME
The canonical name of the 32-bit UTF-32 little-endian charset.static java.lang.String
UTF_8_NAME
The canonical name of the eight-bit UTF-8 charset (to which the big-endian/little-endian byte order does not apply).static java.lang.String
WINDOWS_1252_NAME
The canonical name of the Cp1252 charset.
-
Constructor Summary
Constructors Constructor Description Charsets()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.nio.charset.CharsetDecoder
newDecoder(java.nio.charset.Charset charset, java.nio.charset.CodingErrorAction codingErrorAction)
Convenience method for creating a new decoder from a charset and setting its error handling approach for malformed input and unmappable characters.
-
-
-
Field Detail
-
UTF_8_NAME
public static final java.lang.String UTF_8_NAME
The canonical name of the eight-bit UTF-8 charset (to which the big-endian/little-endian byte order does not apply).- See Also:
- Constant Field Values
-
UTF_16_NAME
public static final java.lang.String UTF_16_NAME
The canonical name of the general 16-bit UTF-16 charset (which requires an initial Byte Order Mark).- See Also:
- Constant Field Values
-
UTF_16BE_NAME
public static final java.lang.String UTF_16BE_NAME
The canonical name of the 16-bit UTF-16 big-endian charset.- See Also:
- Constant Field Values
-
UTF_16LE_NAME
public static final java.lang.String UTF_16LE_NAME
The canonical name of the 16-bit UTF-16 little-endian charset.- See Also:
- Constant Field Values
-
UTF_32_NAME
public static final java.lang.String UTF_32_NAME
The canonical name of the 32-bit UTF-32 charset.- See Also:
- Constant Field Values
-
UTF_32BE_NAME
public static final java.lang.String UTF_32BE_NAME
The canonical name of the 32-bit UTF-32 big-endian charset.- See Also:
- Constant Field Values
-
UTF_32LE_NAME
public static final java.lang.String UTF_32LE_NAME
The canonical name of the 32-bit UTF-32 little-endian charset.- See Also:
- Constant Field Values
-
US_ASCII_NAME
public static final java.lang.String US_ASCII_NAME
The canonical name of the US-ASCII charset.- See Also:
- Constant Field Values
-
ISO_8859_1_NAME
public static final java.lang.String ISO_8859_1_NAME
The canonical name of the ISO-8859-1 charset.- See Also:
- Constant Field Values
-
WINDOWS_1252_NAME
public static final java.lang.String WINDOWS_1252_NAME
The canonical name of the Cp1252 charset.- See Also:
- Constant Field Values
-
-
Method Detail
-
newDecoder
public static java.nio.charset.CharsetDecoder newDecoder(@Nonnull java.nio.charset.Charset charset, @Nonnull java.nio.charset.CodingErrorAction codingErrorAction)
Convenience method for creating a new decoder from a charset and setting its error handling approach for malformed input and unmappable characters.- Parameters:
charset
- The charset from which to create the decoder.codingErrorAction
- The action to take if the data being decoded is invalid.- Returns:
- The new configured decoder.
- See Also:
Charset.newDecoder()
,CharsetDecoder.onMalformedInput(CodingErrorAction)
,CharsetDecoder.onUnmappableCharacter(CodingErrorAction)
-
-