俺写的一个简单的字符串处理函数(可能会有用) - 中国WEB开发者网络 (http://www.webasp.net) -- 技术教程 (http://www.webasp.net/article/) --- 俺写的一个简单的字符串处理函数(可能会有用) (http://www.webasp.net/article/5/4628.htm) |
| -- 作者:未知 -- 发布日期: 2003-07-12 |
| 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; } } } |
| webasp.net |