public class HanZiHePinYin { public static void main(String[] args) { String aa="sdad中国,.ss"; char[] charArray = aa.toCharArray(); for (char c : charArray) { int cnorEn = isCnorEn(c); System.out.println(c+":"+cnorEn); } } static int isCnorEn(char c){ if(c >= 0x0391 && c <= 0xFFE5) //中文字符 return 1; if(c>=0x0000 && c<=0x00FF){ //英文字符 return 2; } return 3; } }
时间: 2024-10-13 12:04:26