package com.ruoyi.common.utils;
|
|
public class ChineseUtils {
|
|
/**
|
* 校验是否是中文
|
*
|
* @param str
|
* @return
|
*/
|
public static boolean isChinese(String str) {
|
for (int i = 0; i < str.length(); i++) {
|
char c = str.charAt(i);
|
if (isChineseCharacter(c)) {
|
return true;
|
}
|
}
|
return false;
|
}
|
|
private static boolean isChineseCharacter(char c) {
|
// 汉字的Unicode编码范围是0x4E00到0x9FA5
|
return c >= 0x4E00 && c <= 0x9FA5;
|
}
|
|
}
|