计算中英文合并的字符串长度
下面介绍一下啊求中英文合并的真正的字符串长度
package com;
import java.io.UnsupportedEncodingException;
/*
* chenhailong
*
*/
public class EnglishString {
public static void main(String[] args) {
String aString = "这是一个测试串,This is a test string.";
String anotherString = null;
try {
anotherString = new String(aString.getBytes("GBK"), "ISO8859_1");
} catch (UnsupportedEncodingException ex) {
}
System.out.println(aString.length() + "," + anotherString.length());
}
}
?输入结果:
Test forward:52,Test last :70
看到了大家字符串长度改变了。。。。。。。。。。。。。
?