首页 > 开发 > 综合 > 正文

俺写的一个简单的字符串处理函数(可能会有用)

2024-07-21 02:27:53
字体:
来源:转载
供稿:网友
using system;

namespace joycode.msn.commandparsers
{
    /// <summary>
    /// 用户编码解释器
    /// </summary>
    internal class encoders
    {
        private static system.text.encoding enc=system.text.encoding.utf8;
        public encoders()
        {
            
            
        }
        
        public static int length(string source)
        {
            
            return enc.getbytecount(source);
        }
        public static int indexof(string source,string find, int start)
        {
            
            
            int result=-1;
            if(start<source.length)
            {
                
                int index=source.indexof(find,start);
                if(index>=0)
                {
                    result=enc.getbytecount(source.substring(0,index));
                }
            }
            return result;
        }
        public static int indexof(string source, string find)
        {
            //            system.text.encoding enc=system.text.encoding.utf8;
            //            int result=enc.getbytecount(source.substring(0,source.indexof(find)));
            return encoders.indexof(source,find,0);
        }
        public static string substring(string source,int start,int count)
        {
            //int c=enc.getbytecount(source);
            string result="";
            try
            {
                result=enc.getstring(enc.getbytes(source),start,count);
            }
            catch
            {
            }
            return result;
            
        }
    }
}



  • 网站运营seo文章大全
  • 提供全面的站长运营经验及seo技术!
  • 发表评论 共有条评论
    用户名: 密码:
    验证码: 匿名发表