参考网址:https://blog.youkuaiyun.com/changjiale110/article/details/78915969
//判断是否存在汉字
public boolean checkcountname(String countname){
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
Matcher m = p.matcher(countname);
if (m.find()) {
return true;
}
return false;
}
//判断整个字符串都由汉字组成
public boolean checkname(String name){
int n = 0;
for(int i = 0; i < name.length(); i++) {
n = (int)name.charAt(i);
if(!(19968 <= n && n <40869)) {
return false;
}
}
return true;
}
汉字编码范围:\u4e00-\u9FA5
双字节字符编码范围:\u0391-\uFFE5
双字节字符编码范围
1.GBK (GB2312/GB18030)
/x00-/xff GBK双字节编码范围
/x20-/x7f ASCII
/xa1-/xff 中文 gb2312
/x80-/xff 中文 gbk
2.UTF-8 (Unicode)
/u4e00-/u9fa5 (中文)
/x3130-/x318F (韩文
/xAC00-/xD7A3 (韩文)
/u0800-/u4e00 (日文)