The following code:
org.apache.commons.lang.StringEscapeUtils.unescapeHtml("Hello World");
gives:
Hello World
But I’d like to know how to get back to the decoded string from “Hello World”. I have tried the escapeHtml method, but this only encodes special characters.
Not true about “anything useful”; if your test string contained HTML special characters like <,>,&, the function would’ve turned it into < > and & (and change other upper ISO8859-1 codes into entities).
If you need to encode it back to Unicode entity format, just iterate through the String codepoints: