Android Question Need convert HEX string to Symbols

Juanll2003uy

Member
Licensed User
Longtime User
Hi, i receive by webservice an string wich have hexadecimal string.
I need to convert it to the symbol string to send to print.

hex.txt is that i receive and cfe.txt is the result that i need.

I saw some examples here with ByteConverter but i couldnt do it.

Someone can help me with this?

Thanks
 

Attachments

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.
 
Upvote 0
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

Code:
            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
 
Last edited:
Upvote 0
First of all, delete your duplicate post, and wrap your code in code tags before Erel or DonManfred sees you.

upload_2018-7-12_22-6-6.png


Your code seems overly complicated. Give regex.split a shot, and don't do any replacing in the hex.txt file, just build a new file.
 
Upvote 0
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.
 
Upvote 0
Yes, but it dont work because i need convert HEX to Symbol before

 into SCAPE
 INTO Data Link Escape
� INTO Null

For example

But i dont find the way
 
Upvote 0
Last edited:
Upvote 0

Similar Threads

Replies
49
Views
13K
  • Article Article
Android Code Snippet [B4X] Hex string to number
Replies
0
Views
6K
  • Locked
  • Article Article
Replies
6
Views
10K
Back
Top