[转载]检测含有中文字符串的实际长度

        System.Text.ASCIIEncoding n = new System.Text.ASCIIEncoding();
        
byte[] b = n.GetBytes("字符串");
        
int l = 0;  // l 为字符串之实际长度 
        for (int i = 0; i <= b.Length - 1; i++)
        
{
            
if (b[i] == 63)  //判断是否为汉字或全脚符号 
            {
                l
++;
            }

            l
++;
        }
posted @ 2007-11-05 14:10  水静痕迹  阅读(92)  评论(0)    收藏  举报