AMP, AT, BACKSLASH, BRACKET_END, BRACKET_START, COLON, COMMA, CR, DASHED, DELIM_END, DELIM_START, DOT, DOUBLE_QUOTES, LF, SINGLE_QUOTE, SLASH, SPACE, TAB, UNDERLINE
Constructor and Description |
---|
CharUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
digit16(int b)
获取给定字符的16进制数值
|
static boolean |
equals(char c1,
char c2,
boolean caseInsensitive)
比较两个字符是否相同
|
static int |
getType(int c)
获取字符类型
|
static boolean |
isAscii(char ch)
是否为ASCII字符,ASCII字符位于0~127之间
CharUtil.isAscii('a') = true
CharUtil.isAscii('A') = true
CharUtil.isAscii('3') = true
CharUtil.isAscii('-') = true
CharUtil.isAscii('\n') = true
CharUtil.isAscii('©') = false
|
static boolean |
isAsciiControl(char ch)
是否为ASCII控制符(不可见字符),控制符位于0~31和127
CharUtil.isAsciiControl('a') = false
CharUtil.isAsciiControl('A') = false
CharUtil.isAsciiControl('3') = false
CharUtil.isAsciiControl('-') = false
CharUtil.isAsciiControl('\n') = true
CharUtil.isAsciiControl('©') = false
|
static boolean |
isAsciiPrintable(char ch)
是否为可见ASCII字符,可见字符位于32~126之间
CharUtil.isAsciiPrintable('a') = true
CharUtil.isAsciiPrintable('A') = true
CharUtil.isAsciiPrintable('3') = true
CharUtil.isAsciiPrintable('-') = true
CharUtil.isAsciiPrintable('\n') = false
CharUtil.isAsciiPrintable('©') = false
|
static boolean |
isBlankChar(char c)
是否空白符
空白符包括空格、制表符、全角空格和不间断空格 |
static boolean |
isBlankChar(int c)
是否空白符
空白符包括空格、制表符、全角空格和不间断空格 |
static boolean |
isChar(Object value)
给定对象对应的类是否为字符类,字符类包括:
Character.class
char.class
|
static boolean |
isCharClass(Class<?> clazz)
给定类名是否为字符类,字符类包括:
Character.class
char.class
|
static boolean |
isEmoji(char c)
判断是否为emoji表情符
|
static boolean |
isFileSeparator(char c)
是否为Windows或者Linux(Unix)文件分隔符
Windows平台下分隔符为\,Linux(Unix)为/ |
static boolean |
isHexChar(char c)
是否为16进制规范的字符,判断是否为如下字符
1. 0~9
2. a~f
4.
|
static boolean |
isLetter(char ch)
判断是否为字母(包括大写字母和小写字母)
字母包括A~Z和a~z CharUtil.isLetter('a') = true CharUtil.isLetter('A') = true CharUtil.isLetter('3') = false CharUtil.isLetter('-') = false CharUtil.isLetter('\n') = false CharUtil.isLetter('©') = false |
static boolean |
isLetterLower(char ch)
检查字符是否为小写字母,小写字母指a~z
CharUtil.isLetterLower('a') = true
CharUtil.isLetterLower('A') = false
CharUtil.isLetterLower('3') = false
CharUtil.isLetterLower('-') = false
CharUtil.isLetterLower('\n') = false
CharUtil.isLetterLower('©') = false
|
static boolean |
isLetterOrNumber(char ch)
是否为字母或数字,包括A~Z、a~z、0~9
CharUtil.isLetterOrNumber('a') = true
CharUtil.isLetterOrNumber('A') = true
CharUtil.isLetterOrNumber('3') = true
CharUtil.isLetterOrNumber('-') = false
CharUtil.isLetterOrNumber('\n') = false
CharUtil.isLetterOrNumber('©') = false
|
static boolean |
isLetterUpper(char ch)
判断是否为大写字母,大写字母包括A~Z
CharUtil.isLetterUpper('a') = false
CharUtil.isLetterUpper('A') = true
CharUtil.isLetterUpper('3') = false
CharUtil.isLetterUpper('-') = false
CharUtil.isLetterUpper('\n') = false
CharUtil.isLetterUpper('©') = false
|
static boolean |
isNumber(char ch)
检查是否为数字字符,数字字符指0~9
CharUtil.isNumber('a') = false
CharUtil.isNumber('A') = false
CharUtil.isNumber('3') = true
CharUtil.isNumber('-') = false
CharUtil.isNumber('\n') = false
CharUtil.isNumber('©') = false
|
static char |
toCloseByNumber(int number)
将[1-20]数字转换为带圈的字符:
1 -》 '①'
12 -》 '⑫'
20 -》 '⑳'
也称作:封闭式字符,英文:Enclosed Alphanumerics
|
static char |
toCloseChar(char c)
将字母、数字转换为带圈的字符:
'1' -》 '①'
'A' -》 'Ⓐ'
'a' -》 'ⓐ'
获取带圈数字 /封闭式字母数字 ,从1-20,超过1-20报错
|
static String |
toString(char c)
字符转为字符串
如果为ASCII字符,使用缓存 |
public static boolean isAscii(char ch)
CharUtil.isAscii('a') = true CharUtil.isAscii('A') = true CharUtil.isAscii('3') = true CharUtil.isAscii('-') = true CharUtil.isAscii('\n') = true CharUtil.isAscii('©') = false
ch
- 被检查的字符处public static boolean isAsciiPrintable(char ch)
CharUtil.isAsciiPrintable('a') = true CharUtil.isAsciiPrintable('A') = true CharUtil.isAsciiPrintable('3') = true CharUtil.isAsciiPrintable('-') = true CharUtil.isAsciiPrintable('\n') = false CharUtil.isAsciiPrintable('©') = false
ch
- 被检查的字符处public static boolean isAsciiControl(char ch)
CharUtil.isAsciiControl('a') = false CharUtil.isAsciiControl('A') = false CharUtil.isAsciiControl('3') = false CharUtil.isAsciiControl('-') = false CharUtil.isAsciiControl('\n') = true CharUtil.isAsciiControl('©') = false
ch
- 被检查的字符public static boolean isLetter(char ch)
CharUtil.isLetter('a') = true CharUtil.isLetter('A') = true CharUtil.isLetter('3') = false CharUtil.isLetter('-') = false CharUtil.isLetter('\n') = false CharUtil.isLetter('©') = false
ch
- 被检查的字符public static boolean isLetterUpper(char ch)
判断是否为大写字母,大写字母包括A~Z
CharUtil.isLetterUpper('a') = false CharUtil.isLetterUpper('A') = true CharUtil.isLetterUpper('3') = false CharUtil.isLetterUpper('-') = false CharUtil.isLetterUpper('\n') = false CharUtil.isLetterUpper('©') = false
ch
- 被检查的字符public static boolean isLetterLower(char ch)
检查字符是否为小写字母,小写字母指a~z
CharUtil.isLetterLower('a') = true CharUtil.isLetterLower('A') = false CharUtil.isLetterLower('3') = false CharUtil.isLetterLower('-') = false CharUtil.isLetterLower('\n') = false CharUtil.isLetterLower('©') = false
ch
- 被检查的字符public static boolean isNumber(char ch)
检查是否为数字字符,数字字符指0~9
CharUtil.isNumber('a') = false CharUtil.isNumber('A') = false CharUtil.isNumber('3') = true CharUtil.isNumber('-') = false CharUtil.isNumber('\n') = false CharUtil.isNumber('©') = false
ch
- 被检查的字符public static boolean isHexChar(char c)
1. 0~9 2. a~f 4. A~F
c
- 字符public static boolean isLetterOrNumber(char ch)
CharUtil.isLetterOrNumber('a') = true CharUtil.isLetterOrNumber('A') = true CharUtil.isLetterOrNumber('3') = true CharUtil.isLetterOrNumber('-') = false CharUtil.isLetterOrNumber('\n') = false CharUtil.isLetterOrNumber('©') = false
ch
- 被检查的字符public static String toString(char c)
c
- 字符ASCIIStrCache.toString(char)
public static boolean isCharClass(Class<?> clazz)
Character.class char.class
clazz
- 被检查的类public static boolean isChar(Object value)
Character.class char.class
value
- 被检查的对象public static boolean isBlankChar(char c)
c
- 字符Character.isWhitespace(int)
,
Character.isSpaceChar(int)
public static boolean isBlankChar(int c)
c
- 字符Character.isWhitespace(int)
,
Character.isSpaceChar(int)
public static boolean isEmoji(char c)
c
- 字符public static boolean isFileSeparator(char c)
c
- 字符public static boolean equals(char c1, char c2, boolean caseInsensitive)
c1
- 字符1c2
- 字符2caseInsensitive
- 是否忽略大小写public static int getType(int c)
c
- 字符public static int digit16(int b)
b
- 字符public static char toCloseChar(char c)
'1' -》 '①' 'A' -》 'Ⓐ' 'a' -》 'ⓐ'
获取带圈数字 /封闭式字母数字 ,从1-20,超过1-20报错
c
- 被转换的字符,如果字符不支持转换,返回原字符public static char toCloseByNumber(int number)
1 -》 '①' 12 -》 '⑫' 20 -》 '⑳'也称作:封闭式字符,英文:Enclosed Alphanumerics
number
- 被转换的数字Copyright © 2024. All rights reserved.