Skip to content

-encoding is not handled correctly for .sc scripts #1390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Gedochao opened this issue Sep 23, 2022 · 1 comment
Open

-encoding is not handled correctly for .sc scripts #1390

Gedochao opened this issue Sep 23, 2022 · 1 comment
Labels
bug Something isn't working scalac compatibility Issues tied with compatibility with the scalac (compiler) command.

Comments

@Gedochao
Copy link
Contributor

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)
€
@Gedochao Gedochao added bug Something isn't working SIP-46 All the issues related to SIP-46 to turn Scala CLI into the official scala runner command. labels Sep 23, 2022
@alexarchambault
Copy link
Contributor

In Scala CLI, for now, UTF-8 is assumed almost everywhere, yeah…

@Gedochao Gedochao added scalac compatibility Issues tied with compatibility with the scalac (compiler) command. and removed SIP-46 All the issues related to SIP-46 to turn Scala CLI into the official scala runner command. labels Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working scalac compatibility Issues tied with compatibility with the scalac (compiler) command.
Projects
None yet
Development

No branches or pull requests

2 participants