Here you can find the source of strLength(String str)
public static int strLength(String str)
public class Main { public static int strLength(String str) { int valueLength = 0; String chinese = "[\u0391-\uFFE5]"; if (!isEmpty(str)) { //from w w w. j av a2 s . c o m for (int i = 0; i < str.length(); i++) { String temp = str.substring(i, i + 1); if (temp.matches(chinese)) { valueLength += 2; } else { valueLength += 1; } } } return valueLength; } public static boolean isEmpty(String str) { return str == null || str.trim().length() == 0; } }