I have a very similar issue as sbt test encoding hickup but since the answer does not apply and my case is in Scala code I ask here.
I have a string containing non ASCII characters in a unit test. This test is working fine on Linux, and fine on Windows when run from IntelliJ. However, when run from a Windows shell with sbt test
they fail. If I print the string humanité
it is displayed as humanitΘ
in the failing case. The file encoding is UTF-8.
println(new java.io.InputStreamReader(System.in).getEncoding)
returns UTF8
when run from IntelliJ, and Cp1252
from the shell. I tried various things to change the encoding:
- run
sbt "-Dfile.encoding=UTF-8" test
- check that scalacOptions defined in my build.sbt contains "-encoding", "UTF8"
But the default encoding is always Cp1252
(maybe that's normal?) and the test keeps failing.
The failing code is the following:
val stringToEncrypt = "l'humanité"
println(test)
From IntelliJ I get:
l'humanité
From a windows shell running sbt:
l'humanitΘ