Reputation: 47
I have to two strings : 1. bookkeeping forms \\u0026 templates 2. hodgkin\u0027s disease
I want to replace \\u0026 with & and \u0027 with '. One of the way is replace their occurrence with corresponding symbol but is there a generic way to deal with this problem ?
Upvotes: 2
Views: 2286
Reputation: 33736
My recommendation is Apache StringScapeUtils
specifically the unescapeJava
method.
Site: https://commons.apache.org/proper/commons-lang/
Maven repo: https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
That method converts unicode to readable text, for example:
String stringWithUnicode; //For example "tendr\\u00e1"
StringScapeUtils.unescapeJava(stringWithUnicode); //This call returns: Tendrá
Upvotes: 3