scala-cli
scala-cli copied to clipboard
-encoding is not handled correctly for `.sc` scripts
Version(s) 0.1.14
Describe the bug
When running a script with non-UTF-8 encoding, even when the -encoding compiler param is passed, it is not respected.
To Reproduce
▶ cat script.sc
println("€")
▶ iconv -f UTF-8 -t CP1252 script.sc > script-CP-1252.sc
▶ cat script-CP-1252.sc
println("�")
▶ scala-cli script.sc
Compiling project (Scala 3.2.0, JVM)
Compiled project (Scala 3.2.0, JVM)
€
▶ scala-cli script-CP-1252.sc
Compiling project (Scala 3.2.0, JVM)
Compiled project (Scala 3.2.0, JVM)
�
▶ scala-cli script-CP-1252.sc -O -encoding -O cp1252
Compiling project (Scala 3.2.0, JVM)
Compiled project (Scala 3.2.0, JVM)
�
Expected behaviour
▶ scala-cli script-CP-1252.sc -O -encoding -O cp1252
Compiling project (Scala 3.2.0, JVM)
Compiled project (Scala 3.2.0, JVM)
€
Additional context
Discovered when spiking for #1310.
This bug only happens with .sc scripts. .scala files are being handled correctly.
▶ cat Main.scala
object Main extends App {
println("€")
}
▶ iconv -f UTF-8 -t CP1252 Main.scala > Main-CP-1252.scala
▶ scala-cli Main.scala
Compiling project (Scala 3.2.0, JVM)
Compiled project (Scala 3.2.0, JVM)
€
▶ scala-cli Main-CP-1252.scala -O -encoding -O cp1252
Compiling project (Scala 3.2.0, JVM)
Compiled project (Scala 3.2.0, JVM)
€
In Scala CLI, for now, UTF-8 is assumed almost everywhere, yeah…