Reputation: 13342
There is a string: Character\5C&\22\3C\3E'
I want to unescape.
There is a code for that:
package escaping;
import org.apache.commons.lang.StringEscapeUtils;
public class UnEscapingDemo {
public static void main(String[] args) {
String str = StringEscapeUtils.unescapeHtml("Character\\5C&\\22\\3C\\3E'");
System.out.println(str);
}
}
But in the end I have not expecting result. I have the same what I've put.. (without converting it)".
Why?
--
Edit:
I believe that "3E" here is stands for ">" .. for example
So, my expecting string is: Character\&"<>'
Upvotes: 0
Views: 282
Reputation: 13342
Well, that weird syntax of escaping comes from OpenLdap...
This works for me then:
public static void main(String[] args) throws UnsupportedEncodingException {
String input = "Character\\5C&\\22\\3C\\3E'";
input = input.replace("\\", "%");
String result = URLDecoder.decode(input, "UTF-8");
System.out.println(result);
}
Upvotes: 0
Reputation: 974
What you mention is not HTML but URI encoding. In HTML, <
would be <
and >
would be >
.
You should take a look at this thread, and read both Tim Cooper and Draemon posts.
Upvotes: 1