简单汉字判断
private static int isCharacter(String word){
byte[] str_byte = null;
str_byte = word.substring(0, 1).getBytes();
if(str_byte.length==2){
return 1;//是汉字
}else{
return 0;//不是汉字
}
}
private static int isCharacter(String word){
byte[] str_byte = null;
str_byte = word.substring(0, 1).getBytes();
if(str_byte.length==2){
return 1;//是汉字
}else{
return 0;//不是汉字
}
}

博客给出了一个简单的汉字判断方法,通过定义 isCharacter 方法,将传入字符串的首个字符转换为字节数组,根据字节数组长度判断是否为汉字,长度为 2 则判定为汉字。
3040

被折叠的 条评论
为什么被折叠?



