判断 前端传到后台的是中文还是字符串

String unitCode = "中国";
char[] charArray = unitCode.toCharArray();
int cnorEn = 0;
for (char c : charArray) {
   cnorEn =+ isCnorEn(c);
}
if(cnorEn < 100){
   System.out.println("中文字符" + unitCode); 
}else{
 System.out.println("英文字符" + unitCode);
}
 

static int isCnorEn(char c){
   if(c >= 0x0391 && c <= 0xFFE5) { //中文字符
      return 1;
   }
   if(c>=0x0000 && c<=0x00FF){  //英文字符
      return 101;
   }
   return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_38029917/article/details/79157616
今日推荐