Intellij Idea incorrect encoding in console output

2019-01-25 09:24发布

It seems to be really crazy, but I can't do anything with broken encoding in console of my intellij idea.

Things I made to overcome this:

  1. Set -Dfile.encoding=UTF-8 and -Dfile.encoding=UTF-8 in both idea.exe.vmoptions and idea64.exe.vmoptions (I use 64 bit version though).
  2. Added -Dfile.encoding=UTF-8 and -Dfile.encoding=UTF-8 to run/debug configuration of my application.
  3. Changed Settings > Editor > File encodings IDE Encoding/Project Encoding/Default encoding for property files to UTF-8.

Having all this done there is still no luck and symbols are not shown correctly in the console. I tried to debug java.io.PrintStream#println(java.lang.String) method and found out that System.out.textOut.out.se.cs equals to windows-1251. No idea where this value is coming from.

This issue have been bothering me for a long period of time and I was unable to find anything in the web that could help me.

Thanks in advance for help.

3条回答
该账号已被封号
2楼-- · 2019-01-25 09:43

My theory is that your java class file are using "windows-1251" encoding, and you need to set it "UTF-8".

looks at the screenshots below. enter image description here enter image description here

To reset all files encoding, you can manually edit encodings.xml. enter image description here You can change the default file encoding in settings dialog. enter image description here

查看更多
叛逆
3楼-- · 2019-01-25 09:46

In my case examining System.out.textOut.out.se.cs in debug hinted that IDEA picked up maven surefire arguments for every JUnit Run Configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <!-- force 7-bit default encoding to ensure that nothing depends on it -->
        <argLine>-Dfile.encoding=ASCII</argLine>
    </configuration>
</plugin>

I've resolved this by adding -Didea.maven.surefire.disable.argLine=true to idea64.exe.vmoptions file.

See also https://www.jetbrains.com/help/idea/configuring-output-encoding.html.

查看更多
Juvenile、少年°
4楼-- · 2019-01-25 10:00

try

-Dconsole.encoding=UTF-8

instead of

-Dfile.encoding=UTF-8
查看更多
登录 后发表回答