orestisf
orestisf

Reputation: 353

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:

scala> sys.props("file.encoding")
res0: String = UTF-8

scala> print("γεια!")
????!
scala> 

enter image description here

Upvotes: 2

Views: 833

Answers (2)

Mario Galic
Mario Galic

Reputation: 48430

Check if the file.encoding is set to UTF-8 by running Scala Console and evaluate

sys.props("file.encoding")

If it does not return

res0: String = UTF-8

then stop and edit Scala Console run configuration. Under VM Options input field enter Unicode file encoding like so

-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> print("γεια!")
γεια!

Upvotes: 2

Qingfei Yuan
Qingfei Yuan

Reputation: 1212

The point is that run/debug console uses the IDEA encoding. IDEA is a java application and encoding can be set in the idea.exe.vmoptions file as ordinary VM parameter. This file lies near your IDEA executabe file and conteins a set of JVM parameters. Add -Dfile.encoding=UTF-8 there to set encoding in 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-

Upvotes: 2

Related Questions