There is such code:

private JTextPane htmlTextPane = new JTextPane(); htmlTextPane.setContentType("text/html;Charset=CP1251"); 

when displaying the contents of the htmlTextPane field using getText () instead of Russian characters, html character codes of the form & # nnnn; What should I do to make Russian characters appear normally instead?

    1 answer 1

     package Test; import javax.swing.*; public class Main { public static void main(String arg[]){ JFrame frame = new JFrame(); frame.setVisible(true); frame.setBounds(0,0,100,100); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JTextPane htmlTextPane = new JTextPane(); htmlTextPane.setContentType("text/html;Charset=CP1251"); frame.add(htmlTextPane); htmlTextPane.setVisible(true); htmlTextPane.setText("asd100023"); System.out.println(htmlTextPane.getText()); } } 

    Conclusion. What's wrong?

     <html> <head> </head> <body> asd100023 </body> </html>