Package org.apache.james.mime4j.util
Class CharsetUtil
java.lang.Object
org.apache.james.mime4j.util.CharsetUtil
Utility class for working with character sets.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isASCII
(char ch) Returnstrue
if the specified character falls into the US ASCII character set (Unicode range 0000 to 007f).static boolean
Returnstrue
if the specified string consists entirely of US ASCII characters.static boolean
isASCII
(ByteSequence raw) Returnstrue
if the specified byte array consists entirely of US ASCII characters.static boolean
isWhitespace
(char ch) Returnstrue
if the specified character is a whitespace character (CR, LF, SP or HT).static boolean
Returnstrue
if the specified string consists entirely of whitespace characters.static Charset
Returns aCharset
instance if character set with the given name is recognized and supported by Java runtime.
-
Field Details
-
CRLF
carriage return - line feed sequence- See Also:
-
CR
public static final int CRUS-ASCII CR, carriage return (13)- See Also:
-
LF
public static final int LFUS-ASCII LF, line feed (10)- See Also:
-
SP
public static final int SPUS-ASCII SP, space (32)- See Also:
-
HT
public static final int HTUS-ASCII HT, horizontal-tab (9)- See Also:
-
-
Constructor Details
-
CharsetUtil
public CharsetUtil()
-
-
Method Details
-
isASCII
public static boolean isASCII(char ch) Returnstrue
if the specified character falls into the US ASCII character set (Unicode range 0000 to 007f).- Parameters:
ch
- character to test.- Returns:
true
if the specified character falls into the US ASCII character set,false
otherwise.
-
isASCII
Returnstrue
if the specified byte array consists entirely of US ASCII characters.- Parameters:
raw
- byte array to test.- Returns:
true
if the specified string consists entirely of US ASCII characters,false
otherwise.
-
isASCII
Returnstrue
if the specified string consists entirely of US ASCII characters.- Parameters:
s
- string to test.- Returns:
true
if the specified string consists entirely of US ASCII characters,false
otherwise.
-
isWhitespace
public static boolean isWhitespace(char ch) Returnstrue
if the specified character is a whitespace character (CR, LF, SP or HT).- Parameters:
ch
- character to test.- Returns:
true
if the specified character is a whitespace character,false
otherwise.
-
isWhitespace
Returnstrue
if the specified string consists entirely of whitespace characters.- Parameters:
s
- string to test.- Returns:
true
if the specified string consists entirely of whitespace characters,false
otherwise.
-
lookup
Returns a
Charset
instance if character set with the given name is recognized and supported by Java runtime. Returnsnull
otherwise.This method is a wrapper around
Charset.forName(String)
method that catchesIllegalCharsetNameException
andUnsupportedCharsetException
and returnsnull
.
-