Android Question parsing text that contain invalid charcters

Addo

Well-Known Member
Licensed User
Longtime User
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

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


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:

OliverA

Expert
Licensed User
Longtime User
i will not write stream any more i will start to change the sending side
What Indy version are you using? Looks like UTF8 encoding seems to vary depending on the version. Here is a blurb from this link (https://stackoverflow.com/a/27710809) You say you come from Delphi. Did you ever have this work with non-Delphi programming languages? If so, what were they? What versions? BTW, it would be nice if you can provide some documentation links to for anything you are using on the Delphi side (including versions), since I seem to be incapable to find a nice documentation source for Indy.
 
Upvote 0

Addo

Well-Known Member
Licensed User
Longtime User
i am using indy 10 which i am thinking i should get ride of it all , i am totally new here all i know were delphi and did not have big knowledge in it either
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…