/**
* 获取字符串的长度,如果有中文,则每个中文字符计为2位
* @param value
* @return
*/
public static int length(String value) {
int valueLength = 0;
String chinese = "[\u0391-\uFFE5]";
for (int i = 0; i < value.length(); i++) {
String temp = value.substring(i, i + 1);
if (temp.matches(chinese)) {//中文字符
valueLength += 2;
} else {
valueLength += 1;
}
}
return valueLength;
}