0

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\&"<>'

user207421
  • 305,947
  • 44
  • 307
  • 483
ses
  • 13,174
  • 31
  • 123
  • 226

2 Answers2

1

What you mention is not HTML but URI encoding. In HTML, < would be &lt; and > would be &gt;.

You should take a look at this thread, and read both Tim Cooper and Draemon posts.

Community
  • 1
  • 1
ssssteffff
  • 964
  • 4
  • 16
0

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

    }
ses
  • 13,174
  • 31
  • 123
  • 226