Hello Guys,
Does someone know which is the right way to get the actual text in these bytes? I do something wrong here.
And another question: is utf-8 the most generic encoding, that will show most of the chars correctly?
TY
private void device_OnPacketArrival(object sender, SharpPcap.CaptureEventArgs e)
{
string str = string.Empty;
var time = e.Packet.Timeval.Date;
var len = e.Packet.Data.Length;
str = "time.Hour: " + time.Hour + " time.Minute: " + time.Minute + " time.Second: " + time.Second + " time.Millisecond: " + time.Millisecond + "len: " + len;
str += Environment.NewLine + e.Packet.ToString();
str += Environment.NewLine + " Message: " + BitConverter.ToString(e.Packet.Data);
//str += e.Packet.Data + Environment.NewLine + Environment.NewLine;
Packet p = Packet.ParsePacket(e.Packet);
str += e.Packet.Data + Environment.NewLine + Environment.NewLine;
byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, e.Packet.Data);
str += Encoding.UTF8.GetBytes(utf8Bytes.ToString()).ToString();
//txtOutput.Text += "time.Hour: " + time.Hour + "time.Minute: " + time.Minute + "time.Second: " + time.Second + "time.Millisecond:" + time.Millisecond + "len:" + len;
//txtOutput.Text += e.Packet.ToString();
//txtOutput.Text += Environment.NewLine;
WriteToFile(str,null);
// WriteToFile("",c);