Reputation: 2687
When you use the Gradle plugin com.devsoap.plugin.vaadin for building Vaadin 8 applications everything works fine as long as you use Linux or Mac. setContent(new Label("A B C Å Ä Ö"))
prints out the characters A B C Å Ä Ö
as expected.
However, if you run the application in Windows the following characters are printed out: A B C Å Ä Ö
.
How can I fix the problem?
See below the essential files in a sample project.
build.gradle
plugins {
id 'com.devsoap.plugin.vaadin' version '2.0.0.beta2'
}
ExampleUI.java
@SuppressWarnings("serial")
public class ExampleUI extends UI {
@Override
protected void init(VaadinRequest request) {
setContent(new Label("A B C Å Ä Ö"));
}
}
ExampleServlet.java
@WebServlet(
asyncSupported=false,
urlPatterns={"/*","/VAADIN/*"},
initParams={
@WebInitParam(name="ui", value="haba713.ExampleUI")
})
public class ExampleServlet extends VaadinServlet {
private static final long serialVersionUID = 1L;
}
Environment
Upvotes: 0
Views: 198
Reputation: 109603
The java sources on Linux and Mac are UTF-8 by the default encoding (editor), and evidently also compiled by UTF-8 (compiler).
On Windows with unchanged sources in the editor Å Ä Ö
would be seen as weird character pairs. If the editor is explicitly set to UTF-8 they are shown correctly.
But evidently the compiler uses the default platform encoding, yielding those pairs.
So set the gradle compiler encoding.
compileJava {
options.encoding = 'UTF-8'
}
(Not much experience with gradle.)
As the IDE often shadows the build process of gradle, also set the editor/compiler encoding to UTF-8.
Upvotes: 2