/**
* 查看字符串字节长度
*
* @param value
* @return
*/
public static int String_length(String value) {
int valueLength = 0;
String chinese = "[\u4e00-\u9fa5]";
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;
}
查看字符串字节长度
最新推荐文章于 2024-04-01 00:30:30 发布