var Mystring = "钓鱼岛是中国的 I love China";
var MyDate = new ASCIIEncoding(); byte[] MyBytes = MyDate.GetBytes(Mystring); var myLength = 0; for (int i = 0; i <= MyBytes.Length - 1; i++) { if (MyBytes[i] == 63)//判断是否为汉字或全脚符号 { myLength++; } myLength++; }本文共 321 字,大约阅读时间需要 1 分钟。
var Mystring = "钓鱼岛是中国的 I love China";
var MyDate = new ASCIIEncoding(); byte[] MyBytes = MyDate.GetBytes(Mystring); var myLength = 0; for (int i = 0; i <= MyBytes.Length - 1; i++) { if (MyBytes[i] == 63)//判断是否为汉字或全脚符号 { myLength++; } myLength++; }转载于:https://www.cnblogs.com/Yellowshorts/archive/2013/02/16/2913560.html