Click here to Skip to main content
15,665,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What encoding format is this? "xx/r/x01/x03/x.../r/n"

I need to convert it into format "78780d0103...0d0a". In python I am able to convert it properly using codecs and decode.

hexbytedata = codecs.encode(received,"hex") hexdata = hexbytedata.decode("utf-8")

Can anyone help me for this in java?

What I have tried:

I have tried jython codec , xml.bind libraries options with no luck
Updated 4-Mar-21 6:11am

1 solution

it's just characters - it's a string representation of the byte values.
Because you can't type "carriage return" (0x0d as a byte) and "line feed" (0x0a as a byte) values on a keyboard, many languages let you insert them to strings using an "escape character" followed by a normal character which says what byte value is to be generated. Often the escape characters is a backslash, but in this case it's a forward slash.
Common escape sequences would probably include:
/r   0x0d   Carriage return
/n   0x0a   Line feed
/t   0x09   Tab
//   0x2f   /
In this case, the "/xyz" would problem mean "the byte value yz in hexadecimal".
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900