i am trying to receive bytes and convert it to string and parse it
the bytes that is string list that saved to a memorystream and send to b4a Asyncstream client socket
the code of new data looks like following
the text that sent from server looks like this
url1~
url2~
Url3~
and so on but after received and convert bytes to string there is some invalid charcters inserted that break the parsing like following
i dont know from where this characters came after bytetostring conversion
now when i try to capture the parsing data as example paramnum(2)
i got an exception
how can i solve this invalid charter after conversion ?
i have used msg = msg.trim with no luck to solve
also i have try to capture if there is any hidden charter that could break that so i used check hidden charcters online i come out with this result
the bytes that is string list that saved to a memorystream and send to b4a Asyncstream client socket
the code of new data looks like following
B4X:
Public Sub NewData (data() As Byte)
Dim msg As String
msg = BytesToString(data, 0, data.Length, "UTF8")
Dim param As String = msg
Dim paramnum() As String = Regex.Split("\~", param)
Log(paramnum(0))
End Sub
the text that sent from server looks like this
url1~
url2~
Url3~
and so on but after received and convert bytes to string there is some invalid charcters inserted that break the parsing like following
B4X:
url1~
������������
url2~
Url3~
i dont know from where this characters came after bytetostring conversion
now when i try to capture the parsing data as example paramnum(2)
i got an exception
main_vvvvvvvvv4 (java line: 489)
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
at app.name.main._vvvvvvvvv4(main.java:489)
at app.name.main._astream_newdata(main.java:381)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:743)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
how can i solve this invalid charter after conversion ?
i have used msg = msg.trim with no luck to solve
also i have try to capture if there is any hidden charter that could break that so i used check hidden charcters online i come out with this result
B4X:
URL1~
URL2~
URL3~
URL4~
URL5~
Last edited: