buggaby
buggaby

Reputation: 441

Character encoding in HTML file using WebView in JavaFX

I have a local HTML file that I would like to display in a WebView, in JavaFX. It's actually an html file from an epub file. I'm essentially trying to build my own epub viewer.

The epub's html file displays some text with diacritic marks. Most of these have been handled in the ebook files using html tags and a CSS, but not all. For example, the character "á" is used. When I open the html file in Chrome, it displays normally, but it shows up in my WebView program as "á".

I assume it's a character encoding thing. If I use the character value a&#769, then it shows up properly, but I'd rather not have to go through all the epub files I want to display and see what other characters don't work properly.

I have saved the html file with UTF-8 encoding, and anyway, it's the same file that is being read by Chrome and my program. Any suggestions?

Upvotes: 1

Views: 807

Answers (1)

buggaby
buggaby

Reputation: 441

Well, that wasn't too long. Explaining the question put me on the path to salvation :)

I just needed to change Eclipse's encoding, using this answer: How to support UTF-8 encoding in Eclipse

  1. Window > Preferences > General > Content Types, set UTF-8 as the default encoding for all content types.
  2. Window > Preferences > General > Workspace, set "Text file encoding" to "Other : UTF-8".

Upvotes: 0

Related Questions