Public Sub NewData (data() As Byte)
Dim msg As String
msg = BytesToString(data, 0, data.Length, "UTF-8")
msg = msg.Trim
msg = msg.Replace(CRLF, "")
msg = msg.Replace(Chr(10), "")
msg = msg.Replace(Chr(13), "")
Dim param As String = msg
Dim paramnum() As String = Regex.Split("\~", param)
Log(paramnum(2))
End Sub
Paramnum(2) raise an exception java.lang.ArrayIndexOutOfBoundsException: length=1; index=2
i have been told in other thread from @DomManFred to remove BOM Header using bytesbuilder which i couldn't figure out how to use it correctly in this manner .
then from server side i already set WriteBOM To false but i am still getting the exception if i try to get Paramnum that its index (1) or (2) or (3)
The weird thing is when i loop through it
B4X:
For i = 0 To paramnum.Length-1
Log(paramnum(i))
Next
i see each one of the splited string without any problems i am trying from yesterday to see a workaround but i couldn't
Based on the Hexdump, my test, Klaus example. you are sending NOT JUST STRING. There are 0x00, 0x01.
If you really send ONLY String followed by CRLF then you can use AsyncStreamText. But you are sending binary data.
Start fixing the Issue on the Sendingside (your Delphi program) to ONLY send Strings.
No I know that I am sending string and stream yes I am aware that I am doing writeln then write at the same time which I think asyncstream can handle without problems which is not the fact
Some people have knowledge some people don't I count my self with very limited knowledge so don't but it doesn't need egel eye to see writeln and write which I already posted , how ever I will stop from being stupid and get a ride of write all together and use writeln after all fail trys .... @keirS
Some people have knowledge some people don't I count my self with very limited knowledge so don't but it doesn't need egel eye to see writeln and write which I already posted , how ever I will stop from being stupid and get a ride of write all together and use writeln after all fail trys .... @keirS
You said you had a problem with calling paramnum(1), paramnum(2) etc. That's because the first time newdata is called it produces an array with exactly zero entries in it. The second time it's called you have received data so it will work.
But you tell me I am wrong despite taking the time to trace through you code. Do you honestly expect people to help you when you keep on telling them they are wrong?
@keirS i did not mention any one as WRONG this will going off the topic You were correct about sending 2 different data at the same time which i posted earlier its okay You are correct .
Yes. It took two pages of post in another thread till he understand that he is using BOM. And it needs my answers to tell him how to change his Delphi-Code not to use BOM.
@keirS i did not mention any one as WRONG this will going off the topic You were correct about sending 2 different data at the same time which i posted earlier its okay You are correct .
I take it English isn't your first language? Because a sentence starting with "No" generally infers that you are disagreeing with what was said. If you are disagreeing with it then that is the same as saying what the other person said is wrong.