简体   繁体   中英

scala default encoding in windows shell

Beginners question: I'm using scala 2.11.4 on a windows 8 machine in the standard command shell (codepage is 850). If I type "Müller" at the scala-prompt scala>"Müller" res0: String = M?ller

The same happens in my first scala trial program:

import scala.io.StdIn.readLine

object Hello {
    def main(args: Array[String]) {
      val myname=readLine("What is your name?","ISO-8859-1")
      println("Hallo " + myname + "!")
    }
}

Calling it via "scala Hello" yields: What is your name?Müller Hallo M?ller!

I guess println uses a different encoding as a default (The "ISO-8859-1"-part did not change anything, by the way)?

scala> System.getProperty("file.encoding")

showed cp1252 . So I generated a environment variable (thanx to Martin Sturm) JAVA_OPTS="-Dfile.encoding=CP850" and currently everything works as expected (München ist schön).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM