自己用的一个求字符串长度的东东,大家可以编译了以后直接引用。

80酷酷网    80kuku.com

  编译|字符串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 ;
            }
        }
    }
}    

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: