[英]Why does IntelliJ's scala console display question marks when I print greek characters?
For example, I observe the following behavior: 例如,我观察到以下行为:
Welcome to Scala 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 12.0.1).
Type in expressions for evaluation. Or try :help.
scala> print("hi!")
hi!
scala> print("γεια!")
????!
How can I fix this? 我怎样才能解决这个问题?
when setting the file.encoding
to UTF-8
I get: 将
file.encoding
设置为UTF-8
我得到:
scala> sys.props("file.encoding")
res0: String = UTF-8
scala> print("γεια!")
????!
scala>
The point is that run/debug console uses the IDEA encoding.
关键是运行/调试控制台使用IDEA编码。 IDEA is a java application and encoding can be set in the idea.exe.vmoptions file as ordinary VM parameter.
IDEA是Java应用程序,可以在idea.exe.vmoptions文件中将编码设置为普通VM参数。 This file lies near your IDEA executabe file and conteins a set of JVM parameters.
该文件位于您的IDEA executabe文件附近,并包含一组JVM参数。 Add -Dfile.encoding=UTF-8 there to set encoding in UTF-8.
在此处添加-Dfile.encoding = UTF-8以设置UTF-8编码。
coming from https://intellij-support.jetbrains.com/hc/en-us/community/posts/206290929-How-can-you-display-UTF-8-characters-in-the-Console-tab- 来自https://intellij-support.jetbrains.com/hc/en-us/community/posts/206290929-How-can-you-display-UTF-8-characters-in-the-Console-tab-
Check if the file.encoding
is set to UTF-8
by running Scala Console
and evaluate 通过运行
Scala Console
检查file.encoding
是否设置为UTF-8
并评估
sys.props("file.encoding")
If it does not return 如果不返回
res0: String = UTF-8
then stop and edit Scala Console
run configuration. 然后停止并编辑
Scala Console
运行配置。 Under VM Options
input field enter Unicode file encoding like so 在“
VM Options
输入字段下,输入Unicode文件编码,如下所示
-Dfile.encoding=UTF-8
Now rerun Scala Console
run configuration, re-evaluate sys.props("file.encoding")
to make sure it says UTF-8
, and then try print("γεια!")
which should now output 现在,重新运行
Scala Console
运行配置,重新评估sys.props("file.encoding")
以确保其显示UTF-8
,然后尝试执行print("γεια!")
,现在应将其输出
scala> print("γεια!")
γεια!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.