I want to preserve html entities while using JSoup. Here is an utf-8 test string from a website:
String html = "<html><body>hello — world</body></html>";
String parsed = Jsoup.parse(html).toString();
If printing the parsed output in utf-8, it looks like the sequence — gets transformed into a character with a code point value of 151.
Is there a way to have JSoup preserve the original entity when outputting as utf-8? If I output in ascii encoding:
Document.OutputSettings settings = new Document.OutputSettings();
settings.charset(Charset.forName("ascii"));
Jsoup.parse(html).outputSettings(settings).toString();
I'll get:
hello — world
which is what I'm looking for.