求助:JEditorPane的getText()方法返回的字符怎么是这样的?输入以下字符(包括中文):
sdf在一枯dsfkl用getText()返回的字符是:
<html>
<head></head>
<body>
sdf&#22312;&#19968;&#26543;dsfkl
</body>
</html>查javadoc是:When the file is passed to an user agent (JEditorPane) it is converted to the document character set (ISO-10646 aka Unicode). 请高手赐教:如何获得中文的html格式文本:
<html>
<head></head>
<body>
sdf在一枯dsfkl
</body>
</html> 

解决方案 »

  1.   

    ISO-10646 用Charset中的类测试,是不支持的,它是不是字符集呀?
      

  2.   

    在你初始化JTextPane的后面,加上一句   .setFont(new Font("gb2312", Font.PLAIN, 12));
      

  3.   

    我用的是:JEditorPane,我用.setFont()方法,但是不行,也应该不行的,还是谢谢楼上的。
      

  4.   

    查j2sdk5的src发现:if (isUTF16Surrogate(c))
                    {
                        writeUTF16Surrogate(c, ch, i, end);
                        i++ ; // process two input characters
                    }
                    else
                    {
                        writer.write("&#");                    String intStr = Integer.toString((int) c);                    writer.write(intStr);
                        writer.write(';');
                    }看来&#后的数字表示char表示的数字值的十进制表示
      

  5.   

    其实就是html的数字转义,可怎样避免连汉字也被转义呢?设置字符集,怎么做呀?