I have a string in java that looks like this "''''<>!@#$%^&", this was escaped in javascript. I need to obtain the original string before escaping the special characters, which is "''''<>!@#$%^&*()".
Asked
Active
Viewed 1,157 times
-4
Matt Ball
- 344,413
- 96
- 627
- 693
user3091472
- 1
- 1
-
http://stackoverflow.com/questions/4841331/url-encode-and-decode-special-character-in-java – bsiamionau Dec 11 '13 at 14:33
-
Your question has already been answered here: http://stackoverflow.com/questions/6138127/how-to-do-url-decoding-in-java – Michaël Benjamin Saerens Dec 11 '13 at 14:35
3 Answers
1
You can use StringEscapeUtils.unescapeHtml4 for this.
For example, the string "<Français>" will become "<Français>"
pascalhein
- 5,530
- 4
- 30
- 41
0
You need to know how it was encoded to reverse it.
If it was URL encoded (which looks likely) then Java has a built in URLDecoder class.
URLDecoder.decode(message, encoding);
Tim B
- 39,784
- 16
- 75
- 127
0
Apache Commons provides utilities for this.
org.apache.commons.lang.StringEscapeUtils.unescapeHtml(String string) should be what you want.
Check out the API here
Dragondraikk
- 1,658
- 11
- 21