0

I have no information about tranform ASCII to hex String. I looked ASCII table in the link ASCII table. However I have really no idea how I can implement this?

ASCII in JSON file:

{ "number": 7,
          "planning": [
            [5,0,[],"2015-11-26 09:00:36",null,["england",2150.4,0,86400,2,1,0,"brighton","holiday"]]
           ]
        }

Hex:

"%7B%20%22number%22%3A%207%2C%0A%20%20%22planning%22%3A%20%5B%0A%20%20%20%20%5B1%2C0%2C%5B%5D%2C%222015-11-26%2009%3A00%3A36%22%2Cnull%2C%5B%22england%22%2C2150.4%2C0%2C86400%2C2%2C1%2C0%2C%22brighton%22%2C%22holiday%22%5D%5D%0A%20%20%20%5D%0A%7D"

For me every ASCII is meaningful but what is the %. Is it escape character?

Thank you for help.

limonik
  • 499
  • 1
  • 6
  • 28
  • 2
    Taka a look here http://stackoverflow.com/questions/6138127/how-to-do-url-decoding-in-java – TDG Dec 24 '15 at 20:34
  • 1
    Implement what? %xx is an escape character to represent an ASCII character using its hex representation. So %7B is asci character 0x7B, (123 in decimal) which is the "{" character, etc. – OldProgrammer Dec 24 '15 at 20:34
  • 1
    It means that the hex number that comes after represents one character – serge Dec 24 '15 at 20:34
  • @TDD Thank you. So somehow I completely wrote my question wrong. I expected to transform String into the URL encoding/Percent-encoding. – limonik Dec 24 '15 at 20:46
  • All ASCII characters are ASCII encoded already. – Peter Lawrey Dec 24 '15 at 21:07

1 Answers1

2

What you describe is the percent-encoding (also known as URI/URL encoding). As you can read on the wiki page, URI/URL only allows a small set of characters. In order to represent others, one uses a percentage (%) followed by the ASCII-code. The percentage symbol is encoded as well (since otherwise it would make the language ambiguous).

This question addresses several ways how you can encode this. You can for instance use:

URIUtil.encodeQuery(url);

Community
  • 1
  • 1
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555