html5中文学习网

您的位置: 首页 > 网络编程 > ASP.NET » 正文

自己用的一个求字符串长度的东东,大家可以编译了以后直接引用。_.NET教程_编程技术

[ ] 已经帮助:人解决问题
编译|字符串
using System;
using System.Text;

namespace PubClass.CSharp.String
{
    public class UTP8String
    {
        public long Length(string strLen)
        {
            bool winnt_chinese=true;
            winnt_chinese=("中国".Length ==2);
            if(winnt_chinese)
            {
                long l,t,c;
                int i;
                l=strLen.Length ;
                t=l;
                for( i=0;i<l;i++)
                {
                    c=(int)strLen[i];
                    if( c<0)
                    {
                        c=c+65536;
                    }
                    if (c>255)
                    {
                        t=t+1;
                    }
                }
                return t;
            }
            else
            {
                return strLen.Length ;
            }
        }
    }
}    
tAcHTML5中文学习网 - HTML5先行者学习网
tAcHTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助