public class Test {
/**
* @param args
*/
public static int getWholeLength(String str) {
int result = 0;
byte[] b = str.getBytes();
for (int i = 0; i < b.length; i++) {
if (b[i] >= 0) {
System.out.println(b[i]);
result = result + 1;
} else {
System.out.println(b[i]);
result = result + 3;// 一个汉字等于3个字符
i++;
}
}
System.out.println(result);
System.out.println("#####################");
return result;
}
public static void main(String[] args) {
getWholeLength("09");
getWholeLength("az");
getWholeLength("AZ");
getWholeLength("a0我");
}
}