TCP报文解析 tcp二进制报文解析 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 static void Run() {//"45 00 80 00 10 00 00 02 01 01 00 0D 66 86 00 00 00 00 00 00 FF FF 14 0E 03 1C 12 15 20 00 14 0E 03 1C 12 15 2E 00 1A AA A0 00 00 00 00 00 00 00 00 00 00 00 00 00 05 02 01 00 08 02 01 00 10 04 90 00 00 00 FF " string data = File.ReadAllText("F:\\1.txt", Encoding.Default).Replace(" ", ""); int result = 0; string output = string.Empty; byte[] array = new byte[1024]; //string[] redata = data.Split(' '); //byte[] newb = new byte[redata.Length]; //for (int i = 0; i < redata.Length; i++) //{ // if (i != 0) // { // Console.Write(" "); // } // //将十进制转换成16进制Begin // newb[i] =Convert.ToByte(redata[i], 16); // //将十进制转换成16进制End // Console.Write(newb[i].ToString()); //} for (int i = 0; i < data.Length; i=i+2) { string di = data.Substring(i, 2); for (int j = 0; j < 2; j++) { string dj = di.Substring(j, 1); #region switch (dj) { case "a": case "A": { result = result * 16 + 10; break; } case "B": case "b": { result = result * 16 + 11; break; } case "C": case "c": { result = result * 16 + 12; break; } case "D": case "d": { result = result * 16 + 13; break; } case "E": case "e": { result = result * 16 + 14; break; } case "F": case "f": { result = result * 16 + 15; break; } default: { result = result * 16 + (string.IsNullOrEmpty(dj.Trim()) ? 0 : Convert.ToInt32(dj)); break; } } #endregion } output += result.ToString()+"|"; array[i] = Convert.ToByte(result); result = 0; } Console.WriteLine(output); Console.WriteLine(Encoding.Unicode.GetString(array)); File.WriteAllBytes("F://2.txt", array); }我的代码 c#中文数据插入到oracle中显示乱码 .net 如何开发适合多核的程序 对于定时操作的服务,设置多长触发检查,怎么判断比较合适 sync block index 里面存储的什么?? [最新下载]不动代码就让DatagridView带有合计、平均值功能的控件 关于EXCEL的打印区域? 有没有在上海交大读软件工程的朋友…… 远程服务器返回错误: (507) Insufficient Storage。 关于windows8客户端与服务端通信的问题 新建phoneapp提示未将对象设置到对象的实例 datagridview 准备开张一个新系统, 技术选型?
{
//"45 00 80 00 10 00 00 02 01 01 00 0D 66 86 00 00 00 00 00 00 FF FF 14 0E 03 1C 12 15 20 00 14 0E 03 1C 12 15 2E 00 1A AA A0 00 00 00 00 00 00 00 00 00 00 00 00 00 05 02 01 00 08 02 01 00 10 04 90 00 00 00 FF "
string data = File.ReadAllText("F:\\1.txt", Encoding.Default).Replace(" ", "");
int result = 0;
string output = string.Empty;
byte[] array = new byte[1024];
//string[] redata = data.Split(' ');
//byte[] newb = new byte[redata.Length];
//for (int i = 0; i < redata.Length; i++)
//{
// if (i != 0)
// {
// Console.Write(" ");
// } // //将十进制转换成16进制Begin
// newb[i] =Convert.ToByte(redata[i], 16);
// //将十进制转换成16进制End // Console.Write(newb[i].ToString());
//}
for (int i = 0; i < data.Length; i=i+2)
{
string di = data.Substring(i, 2);
for (int j = 0; j < 2; j++)
{
string dj = di.Substring(j, 1);
#region
switch (dj)
{
case "a":
case "A":
{
result = result * 16 + 10; break;
}
case "B":
case "b":
{
result = result * 16 + 11; break;
}
case "C":
case "c":
{
result = result * 16 + 12; break;
}
case "D":
case "d":
{
result = result * 16 + 13; break;
}
case "E":
case "e":
{
result = result * 16 + 14; break;
}
case "F":
case "f":
{
result = result * 16 + 15; break;
}
default: {
result = result * 16 + (string.IsNullOrEmpty(dj.Trim()) ? 0 : Convert.ToInt32(dj));
break;
}
}
#endregion
}
output += result.ToString()+"|";
array[i] = Convert.ToByte(result);
result = 0;
}
Console.WriteLine(output);
Console.WriteLine(Encoding.Unicode.GetString(array));
File.WriteAllBytes("F://2.txt", array); }
我的代码