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

来源:互联网 发布:pc3000数据恢复论坛 编辑:程序博客网 时间:2024/05/23 21:38
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
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;
            
        }
    }
}


俺写的一个简单字符串处理函数可能会有用)';return true">
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击