/// <summary>
/// asc码转换进制
/// </summary>
/// <param name="RowCode">要转换的asc码</param>
/// <param name="myBase">进制基数</param>
/// <returns></returns>
private string EncodeResult(string RowCode,int myBase)
{
string strResult="";
try
{
int txtlen=RowCode.Length;
string DesCode="";
int asc=0;
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
for(int i=0;i<txtlen;i++)
{
asc = (int)asciiEncoding.GetBytes(RowCode.Substring(i,1))[0];
DesCode+=Convert.ToString(asc,myBase)+txtSep.Text.Trim();
}
strResult=DesCode;
}
catch(Exception ex)
{
string str=ex.Message;
}
return strResult;
}
/// <summary>
/// 进制转换asc码
/// </summary>
/// <param name="RowCode">要转换的字符串</param>
/// <param name="myBase">进制基数</param>
/// <returns></returns>
private string DecodeResult(string RowCode,int myBase)
{
string strResult="";
try
{
if(txtSep.Text.Trim().Length>0)
{
RowCode=RowCode.Replace(txtSep.Text.Trim(),@"\");
string[] strArrRowCode=RowCode.Split('\\');
int txtlen=strArrRowCode.Length;
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
string strCharacter="";
string strtmp="";
for(int i=0;i<txtlen;i++)
{
strtmp=strArrRowCode[i].Trim();
if(strtmp.Length>0)
{
byte[] byteArray = new byte[] { (byte)Convert.ToByte(strtmp,myBase)};
strCharacter = asciiEncoding.GetString(byteArray);
strResult+=strCharacter;
}
}
}
}
catch(Exception ex)
{
string str=ex.Message;
}
return strResult;
}
/// asc码转换进制
/// </summary>
/// <param name="RowCode">要转换的asc码</param>
/// <param name="myBase">进制基数</param>
/// <returns></returns>
private string EncodeResult(string RowCode,int myBase)
{
string strResult="";
try
{
int txtlen=RowCode.Length;
string DesCode="";
int asc=0;
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
for(int i=0;i<txtlen;i++)
{
asc = (int)asciiEncoding.GetBytes(RowCode.Substring(i,1))[0];
DesCode+=Convert.ToString(asc,myBase)+txtSep.Text.Trim();
}
strResult=DesCode;
}
catch(Exception ex)
{
string str=ex.Message;
}
return strResult;
}
/// <summary>
/// 进制转换asc码
/// </summary>
/// <param name="RowCode">要转换的字符串</param>
/// <param name="myBase">进制基数</param>
/// <returns></returns>
private string DecodeResult(string RowCode,int myBase)
{
string strResult="";
try
{
if(txtSep.Text.Trim().Length>0)
{
RowCode=RowCode.Replace(txtSep.Text.Trim(),@"\");
string[] strArrRowCode=RowCode.Split('\\');
int txtlen=strArrRowCode.Length;
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
string strCharacter="";
string strtmp="";
for(int i=0;i<txtlen;i++)
{
strtmp=strArrRowCode[i].Trim();
if(strtmp.Length>0)
{
byte[] byteArray = new byte[] { (byte)Convert.ToByte(strtmp,myBase)};
strCharacter = asciiEncoding.GetString(byteArray);
strResult+=strCharacter;
}
}
}
}
catch(Exception ex)
{
string str=ex.Message;
}
return strResult;
}