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; }
判断 前端传到后台的是中文还是字符串
最新推荐文章于 2022-10-15 16:31:27 发布