I would like to unescape a XML character entity reference ü
to ü
in Java.
How can I achieve this?
Asked
Active
Viewed 3,321 times
-1

BalusC
- 1,082,665
- 372
- 3,610
- 3,555

user987144
- 75
- 3
- 12
-
2Your question has completely nothing to do with character encoding. The `ü` is just a XML entity, which is an ASCII-safe escaped form of an Unicode codepoint. I removed the encoding/decoding tags from the question as they would only generate incorrect answers from people who know nothing about the matters. – BalusC Jun 19 '13 at 02:00
2 Answers
1
Probably you need an additional library to convert that codes to Unicode chars, like Apache Commons Lang. This library has the class StringEscapeUtils
.
import org.apache.commons.lang3.StringEscapeUtils;
public class Unescape {
public static void main(String[] args) {
String str = StringEscapeUtils.unescapeHtml4("ü");
System.out.println(str);
}
}
Output:
ü

Paul Vargas
- 41,222
- 15
- 102
- 148
0
You can try encoding it as below:
try
{
String str = "üxy";
final String s = new String(str, "UTF-8");
}
catch (UnsupportedEncodingException e)
{
Log.e("utf8", "conversion", e);
}

umangm
- 39
- 3
-
http://stackoverflow.com/questions/13824859/why-is-conversion-from-utf-8-to-iso-8859-1-not-the-same-in-windows-and-linux – umangm Jun 17 '13 at 17:19
-
This answer makes no sense. The `ü` is a [hexadecimal XML entity](http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references), not some [Mojibake](http://en.wikipedia.org/wiki/Mojibake) or whatever you incorrectly thought it was (your answer does basically not solve anything related to character encoding). – BalusC Jun 19 '13 at 01:58
-
Did you create another account to upvote yourself or so? I can't imagine why someone would upvote this nonsensicial answer. – BalusC Jun 19 '13 at 10:35