after i send this packet
byte[] data2 = { 0x00, 0x0E, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x4A, 0x43, 0x50, 0x55, 0x7C, 0x47, 0x45, 0x54 };
stream.Write(data2, 0, data2.Length);
System.Threading.Thread.Sleep(1000);
i'm trying to get some informations from server response.
data2 = new Byte[1024];
bytes = stream.Read(data2, 0, data2.Length);
string responseData = System.Text.Encoding.ASCII.GetString(data2, 0, bytes);
string response = find_str_from_to2(responseData, "galexu", "0|A|CC|");
string intohex = convertAsciiTextToHex(response);
static String convertAsciiTextToHex(String i_asciiText)
{
StringBuilder sBuffer = new StringBuilder();
for (int i = 0; i < i_asciiText.Length; i++)
{
sBuffer.Append(Convert.ToInt32(i_asciiText[i]).ToString("x"));
}
return sBuffer.ToString().ToUpper();
}
the problem is that if the responseData is encoded as: ASCII, UTF-8... etc it doesn't get the real information from the server response.
any ideas?
thank you.
Loading
VulpesPosted Mar 4, 2012, 3:02 PM
andrei hoobaPosted Mar 4, 2012, 2:50 PM
i tought this wouldn't be necessary but.. i need it to contain only 1 number, for ex.: test[3]=05; i need only the '5' number..
VulpesPosted Mar 4, 2012, 12:21 PM
To get the hex representation of the bytes into a string array, you could use this method:
and call with:
andrei hoobaPosted Mar 4, 2012, 11:31 AM
000000050000010200001314200001314200000315400005208000001C9000001C900004B2200000
2141000000050000000200000000000027100000012D800000002004025803100000000000000001
0700000003411361D3000000004014715B25140000000043D7600000000003000000000000000000
0E000100000008
as 28592:
0000000500000102000013880000138800000310D00005208000001900000019000004A17E000002
3900000005000000020000000000002710000001F4000000020040DF310000000000000000860000
000341136115500000000401509815400000000439E6000000000030000000000000000000E00010
0000008
the server is situated in germany.
AS ISO-8859-1, it seems to be OK.
just for not opening a new thread, how can i split these data now into a string[] test to be like:
test[0]= 00;
test[1]=00;
test[2]=00;
test[3]=05;
...
VulpesPosted Mar 4, 2012, 10:50 AM
So it looks like you're using the wrong encoding.
Looking at those you've tried, Default seems the closest overall though Windows 1250 was the only one that got past 0x88.
There are a couple of other Eastern European encodings which might be worth trying 852 and 28592.
Do you know anything about the server such as where it's sited?
andrei hoobaPosted Mar 4, 2012, 9:46 AM
{
int iBegSubstr = sMain.IndexOf(sFrom);
if (iBegSubstr == -1) return "-1";
iBegSubstr += sFrom.Length;
int iEndSubstr = sMain.IndexOf(sTo, iBegSubstr);
if (iEndSubstr == -1) return "-1";
return sMain.Substring(iBegSubstr, iEndSubstr - iBegSubstr);
}
As ASCII:
00000005000001020000133F0000133F0000033F000052080000013F0000013F00004C2C0000003F
000000050000000200000000000027100000013F0000000200403F3100000000000000003F000000
034113613F00000000403F3F3F00000000433F6000000000030000000000000000000E0001000000
08
As UTF-8:
0000000500000102000013FFFD000013FFFD000003FFFD00005208000001FFFD000001FFFD00004C
2C000000FFFD00000005000000020000000000002710000001FFFD000000020040FFFD3100000000
00000000FFFD00000003411361FFFD0000000040558FFFD0000000043FFFD6000000000030000000
000000000000E000100000008
As Default:
00000005000001020000132C60000132C6000003E800005208000001900000019000004C2C000000
C800000005000000020000000000002710000001F4000000020040DF310000000000000000202000
000003411361E00000000040D52DCC0000000004317E6000000000030000000000000000000E0001
00000008
As GetEncoding(1250):
0000000500000102000013880000138800000310D00005208000001900000019000004C900000012
C00000005000000020000000000002710000001F4000000020040DF3100000000000000002020000
00003411361155000000004015098154000000004317E6000000000030000000000000000000E000
100000008
but it should be like:
00000005000001020000138800001388000003E800005208000001900000019000004C2C000000C8
00000005000000020000000000002710000001F4000000020040DF31000000000000000086000000
03411361E00000000040D598C000000000439E6000000000030000000000000000000E0001000000
08
these data
VulpesPosted Mar 4, 2012, 9:00 AM