I am using JDK 1.8.0_201 on Windows 7 with Eclipse Oxygen (4.7.2). I also have Microsoft Internet Explorer 11.0 installed. My java Swing application embeds a SWT Browser. My java code writes a plain text file that contains Hebrew text in "visual order" and saves it with a html extension. I then set the URL for the Browser
to point to the HTML file I just created. When I run the application, the Browser
displays the Hebrew in reverse order. Using an English example, instead of displaying the word Hotel, it displays letoH. Here is the HTML...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO8859-8">
<style type="text/css">
body{font-family:"Miriam Fixed"; font-size:12px;}
</style>
</head>
<body>
<pre>
my Hebrew content
</pre>
</body>
</html>
Here is the java code to write the file
java.io.PrintWriter pw = new java.io.PrintWriter("filename.html", "windows-1255");
pw.println("<html>");
// remainder of "println()" calls to create content as shown above
pw.println("</html>");
pw.close();
Finally, when I run my java application, I explicitly set the file.encoding property in the java command like so...
-Dfile.encoding=UTF-8
I'm guessing it's something in the configuration of my computer but I don't know what and I'm hoping someone can point me in the direction of where to look.
I have not performed exhaustive tests, but nonetheless, so far, the following change to the HTML has resolved the problem. I added tag bdo
as a sub-element of the pre
tag, i.e.
<pre>
<bdo dir="ltr">
my Hebrew content
</bdo>
</pre>
Note that this was the only change. All other code is exactly as it appears in my original question.