Is there something already done to do the following. What I need is a utility class that already implements convertEscapedUTFStringToNormalString for this example or if there isn’t something done then how can I do it?
@Test
public void testConvertEscapedUTFStringToNormalString() {
String expected = "Hello World!";
String escaped = "Hello World\\u0021";
String unescaped = convertEscapedUTFStringToNormalString(escaped);
assertEquals(expected, unescaped);
}
private String convertEscapedUTFStringToNormalString(String escaped) {
//TODO: unimplemented
}
Have you looked at Apache Commons? Their StringEscapeUtils.unescapeJava does what you want, I think. (http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringEscapeUtils.html)