On Scala version 2.11.7, when compiling Scala code on Mac OS X or Linux systems, garbled text may occur if Chinese characters appear.
The solution is as follows: edit the following two execution scripts respectively:
$ vim `which scala` $ vim `which scalac`
Find:
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms32M"
Replace it with:
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms32M -Dfile.encoding=UTF-8"
Recompile the script, and Chinese will then display correctly.