I’m using JTextPane as simple html editor.
jtp=new JTextPane();
jtp.setContentType("text/html;charset=UTF-8");
jtp.setEditorKit(new HTMLEditorKit());
When I call jtp.getText() I get nice html code with all special chars escaped. But I don’t want escape national characters (polish) but only special html chars like &, <, >
When I enter in editor
<foo>ą ś &
I get
<foo>ą ś &
but I would like get
<foo>ą ś &
How it is possile?
That’s not possible, unfortunately.
There’s a flaw inside javax.swing.text.html.HTMLWriter — it is hardcoded to convert any symbol that is not ASCII to its numeric representation:
This logic cannot be controlled in any way.
BUT If you really really need that functionality you could do the crazy stuff:
HTMLWriterHack(in the same packagejavax.swing.text.htmland renaming all strings inside)outputlines with something likeoutput(String.valueOf(chars[counter]));HTMLDocumentHack(in the same packagejavax.swing.text.html, renaming all strings inside, making it extendHTMLDocumentand removing clashing methods)Although the steps above work (I tested it), I certainly wouldn’t recommend doing that.