修复Utility.encodeUTF8Length的bug

This commit is contained in:
Redkale
2019-09-19 21:22:47 +08:00
parent f706209ec1
commit edbc878b73

View File

@@ -1924,7 +1924,15 @@ public final class Utility {
final int limit = start + len;
for (int i = start; i < limit; i++) {
c = chars[i];
size += (c < 0x80 ? 1 : (c < 0x800 ? 2 : 3));
if (c < 0x80) {
size++;
} else if (c < 0x800) {
size += 2;
} else if (Character.isSurrogate(c)) {
size += 2;
} else {
size += 3;
}
}
return size;
}