website compilation fails with `error: unmappable character for encoding ASCII`
Compiling the metrics website in our reproducible builds system results in:
[javac] /var/tmp/build/metrics-web-23437dd19d7a/src/main/java/org/torproject/metrics/web/UpdateNews.java:109: error: unmappable character for encoding ASCII
[javac] .replaceAll("??", "×")
[javac] ^
[javac] /var/tmp/build/metrics-web-23437dd19d7a/src/main/java/org/torproject/metrics/web/UpdateNews.java:109: error: unmappable character for encoding ASCII
[javac] .replaceAll("??", "×")
[javac] ^
[javac] /var/tmp/build/metrics-web-23437dd19d7a/src/main/java/org/torproject/metrics/web/UpdateNews.java:110: error: unmappable character for encoding ASCII
[javac] .replaceAll("??", "§")
[javac] ^
[javac] /var/tmp/build/metrics-web-23437dd19d7a/src/main/java/org/torproject/metrics/web/UpdateNews.java:110: error: unmappable character for encoding ASCII
[javac] .replaceAll("??", "§")
[javac] ^
[javac] /var/tmp/build/metrics-web-23437dd19d7a/src/main/java/org/torproject/metrics/web/UpdateNews.java:111: error: unmappable character for encoding ASCII
Looking at the respective code we see:
.replaceAll("×", "×")
.replaceAll("§", "§")
.replaceAll("–", "–")
. So, yes, the ASCII complaint makes sense, in particular if you don't have an UTF-8 environment. This looks pretty similar to https://github.com/mimno/Mallet/issues/159. And, yes, settings the encoding to UTF-8 for javac
in the build.xml
file in the base
project does indeed fix the problem.
I am not sure, though, whether we should do that given that the base
project is used by all the other metrics projects, too. However, I think setting the javac
encoding is the right fix if one has non-ASCII characters in sources files.
/cc @irl