Android Question SEND HEX STRING OVER TCP/IP

rkxo

Active Member
Licensed User
Hi,
When I try to send a hexadecimal string via tcp from a client I have problems as the hextobytes function converts some negative values. When I convert this byte array to an int array and send it the values that appear on the server, some values that I don't quite understand. I would like the hex string that I send to appear on the server as it is. someone knows why it doesn't work for me.



Hex array:
    Dim Buffer() As Byte=Array As Byte(0x02,0x20,0x1A,0x31,0x31,0x31,0x32,0x33,0x5E,0x4C,0x10,-->0x83<---(correct byte),0x18,0x18,0x18,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00-->,0xE5,0xF5<---,0x03)
    astream.write(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
when i send with charset utf8,ascii, i receive
{02}{20}{1A}{31}{31}{31}{32}{33}{5E}{4C}{10}-->{EF}{BF}{BD}<--{18}{18}{18}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{0A}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{0A}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{00}-->{EF}{BF}{BD}{EF}{BF}{BD}<----{03}
when i sendwith charset iso8859-1 i receive this

{02}{20}{1A}{31}{31}{31}{32}{33}{5E}{4C}{10}-->{C2}{83}<---{18}{18}{18}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{0A}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{0A}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{00}-->{C3}{A5}{C3}{B5}<---{03}]

the correct string i should receive is
{02}{20}{1A}{31}{31}{31}{32}{33}{5E}{4C}{10}-->{83}<--{18}{18}{18}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{0A}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{0A}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{20}{00}-->{A5}{B5}<---{03}]

What type of charset should I use to receive the string equal to the one I sent?


Thank you
 
Last edited:

rkxo

Active Member
Licensed User
hi,
When i compile...
hex raw:
Try
        Dim bc As ByteConverter

        Dim HexString As String=bc.HexFromBytes(Array As Byte(0x02,0x20,0x1A,0x31,0x31,0x31,0x32,0x33,0x5E,0x4C,0x10,0x83,0x18,0x18,0x18,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0xE5,0xF5,0x03))
        astream.write(HexString.GetBytes("UTF8"))
    Catch
        Log(LastException)
    End Try

appears this error
astream.write(HexString.GetBytes(\
javac 1.8.0_161
src\pmv\aluvisagrupo\com\starter.java:211: error: no suitable method found for NumberToString(byte[])
_astream._write /*String*/ (null,BA.NumberToString(_hexstring.getBytes("UTF8")));
^
method BA.NumberToString(double) is not applicable
(argument mismatch; byte[] cannot be converted to double)
method BA.NumberToString(float) is not applicable
(argument mismatch; byte[] cannot be converted to float)
method BA.NumberToString(int) is not applicable
(argument mismatch; byte[] cannot be converted to int)
method BA.NumberToString(long) is not applicable
(argument mismatch; byte[] cannot be converted to long)
method BA.NumberToString(Number) is not applicable
(argument mismatch; byte[] cannot be converted to Number)

any idea?
 
Upvote 0
Top