I would use regex.split. First split on &# to get each chunk with hex code and potentially trailing non-hex text. Then iterate over that list, and on each chunk another regex.split, this time on the ;. First match will be the hexcode that you need to convert to a char, and if there's another match, that's just pure text to add.
Hi Sandman, i have tried with this code, to find all the hex elements and try to convert to symbol
But when the hex is for example "�" it crush in bconv.HexToBytes("�")
And the symbols that i receive arent the correct in the string
I dont know if the functions that i use are the correct to it
B4X:
i=PrintBuffer.IndexOf("&#")
j=PrintBuffer.IndexOf2(";",i)
Do While i >= 0
bytearray=Null
bytearray = bconv.HexToBytes(PrintBuffer.SubString2(i,j+1))
PrintBuffer=PrintBuffer.Replace(PrintBuffer.SubString2(i,j+1), bconv.StringFromBytes(bytearray, "UTF8"))
i=PrintBuffer.IndexOf("&#")
j=PrintBuffer.IndexOf2(";",i)
Loop
This does not appear to be any standard byte encoding scheme that I am familiar with. Where is this data coming from? I'm guessing that whatever is sending it should tell you how to interpret it in their SDK or API documentaion.
Ah, I understand now! The string you're getting is not byte encoded, it his HTML Encoded. I suggest you search here or on the web for HTML decoding a string.
In VB.NET you would use the System.Web.HttpUtility.HtmlDecode function to return a string with all the escaped characters converted to their ASCII values, I do not think B4A/X has a built-in equivalent, hence the link I provided.