lengthWithChinese static method
计算字符串长度(中文算两个字符) Calculate string length (Chinese characters count as two)
Implementation
static int lengthWithChinese(String str) {
int length = 0;
for (final rune in str.runes) {
length += rune > 255 ? 2 : 1;
}
return length;
}