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