0

I got a bridge with JavaScript and it gives me some bad input that looks as below, I need to fix it on my side.

String input = "\u003chtml\u003e\u003cbody\u003eMoved\u003c/body\u003e\u003c/html\u003e\n";

I want to decode it to this output:

String output = decode(input);
System.out.println(output);

It should print the below line(like in this nice tool)

<html><body>Moved</body></html>

alexbt
  • 16,415
  • 6
  • 78
  • 87
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
  • The string already has the content you expect (assuming the `String input = "..."` is part of a `.java` file). If it is not, where/how are you getting the data? – Mark Rotteveel Jul 19 '16 at 11:11
  • What does it print? – user4759923 Jul 19 '16 at 11:11
  • @MarkRotteveel I got a bridge with javascript and some thing goes wrong there, so I need to fix it on my side. This is the input that I am getting – Ilya Gazman Jul 19 '16 at 11:15
  • @Ilya_Gazman You should edit your question with that information, because it is pretty important, and as it stands the code shown doesn't demonstrate your problem. – Mark Rotteveel Jul 19 '16 at 11:15
  • `String str = StringEscapeUtils.unescapeJava(path);` – bananas Jul 19 '16 at 11:31
  • download jar from here (https://commons.apache.org/proper/commons-lang/download_lang.cgi) – bananas Jul 19 '16 at 11:31
  • The above is simply `"Moved"`. Executed as java one gets this value. It is u-escaping, normally of non-ASCII, here of `<` and `>` - maybe for XML. `StringEscapeUtils.unescapeJava` will help too. – Joop Eggen Jul 19 '16 at 11:32

0 Answers0