Java 为什么JSOUP不读作UTF-8?
我想将jsoup解析为utf-8,但我做不到。我尝试我知道的一切,我在谷歌上搜索 我的目标是什么:Java 为什么JSOUP不读作UTF-8?,java,html,utf-8,jsoup,Java,Html,Utf 8,Jsoup,我想将jsoup解析为utf-8,但我做不到。我尝试我知道的一切,我在谷歌上搜索 我的目标是什么: String tmp_html_content ="Öç"; InputStream is = new ByteArrayInputStream(tmp_html_content.getBytes()); Document doc_tbl = Jsoup.parse(is, "UTF-8", ""); doc_tbl.outputSettings().charset
String tmp_html_content ="Öç";
InputStream is = new ByteArrayInputStream(tmp_html_content.getBytes());
Document doc_tbl = Jsoup.parse(is, "UTF-8", "");
doc_tbl.outputSettings().charset().forName("UTF-8");
doc_tbl.outputSettings().escapeMode(EscapeMode.xhtml);
但是doc\u tbl
不是UTF-8
请帮忙
public static void main(String []args){
System.out.println("Hello World");
String tmp_html_content ="Öçasasa";
InputStream is = new ByteArrayInputStream(tmp_html_content.getBytes());
org.jsoup.nodes.Document doc_tbl;
try {
doc_tbl = Jsoup.parse(is, "ISO-8859-9", "");
((org.jsoup.nodes.Document) doc_tbl).outputSettings().charset().forName("UTF-8");
((org.jsoup.nodes.Document) doc_tbl).outputSettings().escapeMode(EscapeMode.xhtml);
String htmlString = doc_tbl.toString();
System.out.println(htmlString);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
发出
你好,世界
çasasa
您可以尝试ISO-8859-9,而不是UTF-8。您是否遇到错误或输出结果是否仍然不同,如Ç;它不会在我的jsoup(1.7.3)上给出错误。输出为->Hello WorldÃçasasa@virgula24 u可以使用ISO-8859-1字符集