Why JSOUP does not read as UTF-8?

前端 未结 1 527
时光说笑
时光说笑 2021-01-24 18:45

I want to jsoup parse as utf -8 but I cant. I try everything I know and I searched on google.

What is my goal:

String tmp_html_content =\"Öç\";

InputStr         


        
相关标签:
1条回答
  • 2021-01-24 19:26
    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();
    
            } 
    
         }
    

    out put

    Hello World Öçasasa

    0 讨论(0)
提交回复
热议问题