Print webview content on windows with utf-8

1

I'm trying to print the contents of the webview in javafs 2.2, on windows and special nonfunctional characters, (vowels accented, ç ...) I already changed the application charset as follows:

public static void main(String[] args) {
    System.setProperty("file.encoding","UTF-8");
    Field charset = null;
    try {
        charset = Charset.class.getDeclaredField("defaultCharset");
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
    charset.setAccessible(true);
    try {
        charset.set(null,null);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    TagSellApp.launch( args );
}

Also when I write the file to load in the webview, in this case I get a document Document provided from the org.jsoup library:

private void initializeWebView(Document document) {
    File file = new File(".tmp/poster.html");

    try {
        FileWriter rec = new FileWriter(file);
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file, false), StandardCharsets.UTF_8));
        writer.println(document.outerHtml());
        writer.close();
        rec.close();

        webEngine.load( file.toURI().toURL().toString() );
    } catch (IOException ex) {
        ex.printStackTrace();
    }

    webEngine.reload();
}

before this when I upload Document myself:

html.charset( StandardCharsets.UTF_8 );

And even then, none of this works on windows, I've tried other encoding like CP1252m Iso 8859-1 and the damn windows do not work ... to a few days researching solutions I've done countless tests, someone has already gone through this and has the solution ? Thank you in advance!

    
asked by anonymous 18.09.2017 / 22:37

0 answers