I have a situation where I receive x-www-form-urlencoded form data and I need to decode it.
how to decode x-www-form-urlencoded form data in java which has an unescaped % as data. e.g. "APL%205%%20off" which actually shall be decoded as "APL 5% off" However, I tried a few code snippets in java as well as a few online decoders and all throw an exception or say invalid.
I need the understanding on how this can be achieved? If anyone can share the knowledge would be greatly appreciated.
'%' in urlEncode encoding is '%25', so decoding 'APL%205%%20off' will cause issues. Normally, it should be encoded as 'APL%205%25%20off' to decode and get the expected result "APL 5% off". If you must decode this string, you can try the following code:
or try this