c#里面可以这样判断:
ASCIIEncoding n = new ASCIIEncoding();
byte[] b = n.GetBytes(str);
int l = 0; // l 为字符串之实际长度
for (int i=0;i <= b.Length-1;i++)
{
if (b[i] ==63) //判断是否为汉字或全脚符号
{
l++;
}
l++;
}
JAVA里面是这样判断中文长度的:
public class LengTest {
public static void main(String[] args) throws Exception{
System.out.println("Hello");
String str = new String("wwwwÎÒÎÒqxbird");
int len = new String(str.getBytes("gb2312"),"8859_1").length();
System.out.println(len);
}
}
也许你可以从这里得到答案!!