Package org.apache.james.mime4j.util
Class CharsetUtil
- java.lang.Object
-
- org.apache.james.mime4j.util.CharsetUtil
-
public class CharsetUtil extends Object
Utility class for working with character sets.
-
-
Constructor Summary
Constructors Constructor Description CharsetUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isASCII(char ch)
Returnstrue
if the specified character falls into the US ASCII character set (Unicode range 0000 to 007f).static boolean
isASCII(String s)
Returnstrue
if the specified string 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
isWhitespace(String s)
Returnstrue
if the specified string consists entirely of whitespace characters.static Charset
lookup(String name)
Returns aCharset
instance if character set with the given name is recognized and supported by Java runtime.
-
-
-
Field Detail
-
CRLF
public static final String CRLF
carriage return - line feed sequence- See Also:
- Constant Field Values
-
CR
public static final int CR
US-ASCII CR, carriage return (13)- See Also:
- Constant Field Values
-
LF
public static final int LF
US-ASCII LF, line feed (10)- See Also:
- Constant Field Values
-
SP
public static final int SP
US-ASCII SP, space (32)- See Also:
- Constant Field Values
-
HT
public static final int HT
US-ASCII HT, horizontal-tab (9)- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public static boolean isASCII(String s)
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
public static boolean isWhitespace(String s)
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
public static Charset lookup(String name)
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
.
-
-