Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I found the cause of the problem, and a solution to make it work as it should. As I already suspected after posting my question and reading the answer of Calum and issues with encoding on the Mac with another project (which was in Java), the cause of the problem is the default encoding used by Mac OS X. When you start <code>scala</code> interpreter, it will use the default encoding for the specified platform. On Mac OS X, this is Macroman, on Windows it is probably CP1252. You can check this by typing the following command in the scala interpreter:</p> <pre><code>scala&gt; System.getProperty("file.encoding"); res3: java.lang.String = MacRoman </code></pre> <p>According to the <code>scala</code> help test, it is possible to provide Java properties using the -D option. However, this does not work for me. I ended up setting the environment variable </p> <pre><code>JAVA_OPTS="-Dfile.encoding=UTF-8" </code></pre> <p>After running <code>scala</code>, the result of the previous command will give the following result:</p> <pre><code>scala&gt; System.getProperty("file.encoding") res0: java.lang.String = UTF-8 </code></pre> <p>Now, printing special characters works as expected:</p> <pre><code>print(0x20AC.toChar) € </code></pre> <p>So, it is not a bug in Scala, but an issue with default encodings. In my opinion, it would be better if by default UTF-8 was used on all platforms. In my search for an answer if this is considered, I came across a <a href="http://thread.gmane.org/gmane.comp.lang.scala.internals/189" rel="noreferrer">discussion</a> on the Scala mailing list on this issue. In the first message, it is proposes to use UTF-8 by default on Mac OS X when <code>file.encoding</code> reports Macroman, since UTF-8 is the default charset on Mac OS X (keeps me wondering why <code>file.encoding</code> by defaults is set to Macroman, probably this is an inheritance from Mac OS before 10 was released?). I don't think this proposal will be part of Scala 2.8, since Martin Odersky <a href="http://article.gmane.org/gmane.comp.lang.scala.internals/298" rel="noreferrer">wrote</a> that it is probably best to keep things as they are in Java (i.e. honor the <code>file.encoding</code> property).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload