public static long countBytes(String s, boolean shortLength) throws UTFDataFormatException {
long result = 0;
int length = s.length();
int i = 0;
while (i < length) {
char ch = s.charAt(i);
if (ch != '\u0000' && ch <= '') {
result++;
} else if (ch <= '߿') {
result += 2;
} else {
result += 3;
}
if (!shortLength || result <= 65535) {
i++;
} else {
throw new UTFDataFormatException("String more than 65535 UTF bytes long");
}
}
return result;
}
Mutf8.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:boohee_v5.6
作者:
评论列表
文章目录