Whats wrong with Scala encoding?
I guess something is wrong with Scala while displaying "\303\251" unicode. Ideally it should display "Ã©" but instead it is displaying "ÃÂ©".
I tried with several scala versions like 2.10.4, 2.10.5 & 2.11.8 but i got the same output (i.e., ÃÂ©).
$ JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 sbt Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 > console Welcome to Scala version 2.11.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_71). scala> print ("\303\251") ÃÂ© scala> System.getProperty("file.encoding"); res2: String = UTF8
even i used equivalent hex escape literals for \303\251 i.e., \u00c3\u00a9, still the same output
scala> print ("\u00c3\u00a9") ÃÂ©
Note: I face this issue only in Linux and Ubuntu OS but in MAC it works very fine as shown below:
scala> print ("\303\251") Ã©
I didn't understand why scala is giving wrong output in linux & ubuntu machines. Does anyone faced this issue? Please let me know how to fix this. Thanks for your time and help.
Yes, Linux character encoding is the issue. After changing the environment variable LANG (as shown below), everything works properly.
/usr/bin/env LANG=en_US.UTF-8 /usr/bin/xterm