日期:2012-07-21  浏览次数:20391 次

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 ;
            }
        }
    }
}