Windows外壳中的scala默认编码 [英] scala default encoding in windows shell

查看:138
本文介绍了Windows外壳中的scala默认编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

初学者问题:我在标准命令shell(代码页为850)的Windows 8机器上使用scala 2.11.4。
如果我在scala提示符处输入Müller
scala>Müller
res0:String = M?ller

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

在我的第一个scala试用程序中也是如此:

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 + "!")
    }
}

通过scala Hello得到:
你叫什么名字?Müller
Hallo M?ller!

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

我猜println使用不同的编码默认(ISO-8859-1 - 没有改变任何东西,顺便说一下)?

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

推荐答案

scala>系统.getProperty(file.encoding)显示cp1252。
所以我生成了一个环境变量(thanx to Martin Sturm)
JAVA_OPTS = - Dfile.encoding = CP850
,目前一切都按照预期(Münchenistschön)工作。

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).

这篇关于Windows外壳中的scala默认编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆