I have a string with HTML
encoding like below:
Ðột nhiên, ở gốc Tây Bắc văng vẳng có tiếng vó ngựa dồn dập.
I want to convert this String
to Unicode
.
Expected output:
Ðột nhiên, ở gốc Tây Bắc văng vẳng có tiếng vó ngựa dồn dập.
I found a solution by Convert Decimal NCRs Code into UTF-8 in java (JSP) but it only works for strings with all characters which has its format begins with &#
.
With characters begin with &xxxx
, using the page HTML encoding of foreign language characters I got its encode is html encoding but my input string is the combination of convert HTML Entity (named) and HTML Entity (decimal).
Does anyone have any suggestion? It would be the best if we can make it without adding any additional libraries.
[UPDATE] I solved my problem by using Apache library :
String encodeString = "Ðột nhiên, ở gốc Tây Bắc văng vẳng có tiếng vó ngựa dồn dập.";
String unEncodeString = StringEscapeUtils.unescapeHtml4(encodeString);
System.out.println("OUTPUT : " + unEncodeString);
=====> OUTPUT : Ðột nhiên, ở gốc Tây Bắc văng vẳng có tiếng vó ngựa dồn dập.