public static int byteNum(String str) { int m = 0; char arr[] = str.toCharArray(); for(int i=0;i<arr.length;i++) { char c = arr[i]; if((c >= 0x0391 && c <= 0xFFE5)) //中文字符 { m = m + 2; } else if((c>=0x0000 && c<=0x00FF)) //英文字符 { m = m + 1; } } return m; }
原文地址:https://www.cnblogs.com/lansetuerqi/p/8744086.html
时间: 2024-10-08 04:02:22