I try to escape and unescape large text using the StringEscapeUtils from Apache Commons library (v. 1.7) that will be stored and retrieved from a database, in this case a H2 database. Almost every special character is escaped and unescaped successfully except for the new line. I am using Spring Boot (v2.1.3.) with thymeleaf.
So for instance, if I try to store the following text:
He didn't say, "Stop!" This is a new line!
It will store the text as:
He didn't say, \"Stop!\"\r\n\r\nThis is a new line!
Which is good. But when I unescape it with the unescapeJava method the new line character is not working correctly. I get
He didn't say, "Stop!" This is a new line!
Edit:
The unescapeJava method works when the text is displayed in a html textarea. But when it is rendered as plain html, the linebreak is not working.