代码如下:
public static int getCharLength(String content) {
int count = 0;
for (int i = 0, len = content.length(); i len; ++i) {
if ('u4E00' = content.charAt(i) && 'u9FBB' = content.charAt(i)) {
count++;
}
}
return content.length()+count;
}
其它的编码方式可以按照这个原理去时行计算
猜你喜欢