limonik
limonik

Reputation: 499

ASCII to Hex-Java

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.

Upvotes: 0

Views: 362

Answers (1)

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 476557

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);

Upvotes: 2

Related Questions