Results encoding in Scala Worksheet Eclipse plugin

后端 未结 2 411
攒了一身酷
攒了一身酷 2021-01-20 12:47

How can I change charset encoding for results in the Worksheet in Eclipse?

object workbook1 {
\"cyrillic A is: \" + \"А\"  //> res0: String(\"cyrylic A is         


        
相关标签:
2条回答
  • 2021-01-20 13:23

    Many thanks to @Excelan's original question and solution as it definitely got me pointed in the right direction!

    I was experiencing this problem using the Scala Eclipse IDE when working with new projects I created, but was not experiencing the problem when using imported projects. Once I saw Excelan's comment about the encoding I started poking around, you can change the Eclipse default text file encoding for all projects in the Preferences like so:

     Open Preferences
     Expand the "General" menu.
     Select the "Workspace" menu.
     Change "Text file encoding" option from Default to Other and select UTF-8.
    

    Once I followed those steps, closed and reopened eclipse. Every new worksheet created after that works just fine!

    Screencap of preferences

    To change the settings on a project level, right click the project and select properties. The text file encoding is found under the "Resources" menu.

    To change the settings for a single file, right click the file and select properties. The text file encoding is found under the "Resources" menu.

    0 讨论(0)
  • 2021-01-20 13:30

    This happens because JVM handles input strings as encoded with system default (cp1251 in my case)

    You should say to JVM that input strings are in UTF-8 To do this, put into your eclipse.ini:

    -Dfile.encoding=UTF8

    If there is better (project local) solution, please let me know. This seems to be Windows-only related question.

    0 讨论(0)
提交回复
热议问题