rbsoft Active Member Licensed User Longtime User Aug 30, 2011 #1 In the following piece of code the value Chr(254) is not properly translated. Code: t = "&&ID|" & MyIP & "|1|42" & Chr(254) Buffer = t.GetBytes("UTF8") OutputStream1.WriteBytes(Buffer,0,t.Length) The receiving program gets everything right except that Chr(254) has changed into Chr(195). Any idea what I am doing wrong? Rolf PS: Just noted in the Debugger that Chr(254) gets translated into Chr(-61) & Chr(-66). Number of bytes became 21 instead of 20. Last edited: Aug 30, 2011
In the following piece of code the value Chr(254) is not properly translated. Code: t = "&&ID|" & MyIP & "|1|42" & Chr(254) Buffer = t.GetBytes("UTF8") OutputStream1.WriteBytes(Buffer,0,t.Length) The receiving program gets everything right except that Chr(254) has changed into Chr(195). Any idea what I am doing wrong? Rolf PS: Just noted in the Debugger that Chr(254) gets translated into Chr(-61) & Chr(-66). Number of bytes became 21 instead of 20.
K kickaha Well-Known Member Licensed User Longtime User Aug 30, 2011 #2 Chr 254 translated to unicode is two bytes C3, BE, or 195, 190 in decimal. These values translate to -61, -66 as signed 8 bit integers so things are working as they should. Not sure what you are doing, but it seems that you need to use different encoding. Upvote 0
Chr 254 translated to unicode is two bytes C3, BE, or 195, 190 in decimal. These values translate to -61, -66 as signed 8 bit integers so things are working as they should. Not sure what you are doing, but it seems that you need to use different encoding.
rbsoft Active Member Licensed User Longtime User Aug 30, 2011 #3 I use Chr(254) as an end delimiter in a TCP/IP protocol I am using for many years. I tried UTF16 and ASCII encoding but without success. Upvote 0
I use Chr(254) as an end delimiter in a TCP/IP protocol I am using for many years. I tried UTF16 and ASCII encoding but without success.
Erel B4X founder Staff member Licensed User Longtime User Aug 30, 2011 #4 Why not send the byte 254 instead of first converting it to string? Upvote 0
rbsoft Active Member Licensed User Longtime User Aug 30, 2011 #5 How would I do that? Could you give 2 or 3 lines of code? Somehow I am not able to grasp it. Rolf Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Aug 30, 2011 #6 You can send a single byte by calling: Code: OutputStream1.WriteBytes(Array As Byte(254), 0, 1) Upvote 0
rbsoft Active Member Licensed User Longtime User Aug 30, 2011 #8 Yep - that did the job! My communication routines work. Thanks also, kickaha, for the information. Rolf Upvote 0
Yep - that did the job! My communication routines work. Thanks also, kickaha, for the information. Rolf