IntelliJ IDEA incorrect encoding in console output

33,390

Solution 1

This works for me.

  1. Close your intellij idea
  2. Search and open file idea.exe.vmoptions inside idea installed, for example: "C:\Program Files\JetBrains\IntelliJ IDEA 2018.3.2\bin". After add next line: -Dfile.encoding=UTF-8
  3. (Optional) if you have file idea64.exe.vmoptions, add the same line too.
  4. Start your intellij idea.

Solution 2

try

-Dconsole.encoding=UTF-8

instead of

-Dfile.encoding=UTF-8

Solution 3

You may have modified the wrong file,

not : C:\Program Files\JetBrains\IntelliJ IDEA xxxx\bin\idea64.exe.vmoptions

should be: C:\Users\USER_NAME\.IntelliJIdeaxxxx\config\idea64.exe.vmoptions

you can add both -Dfile.encoding=UTF-8 and -Dconsole.encoding=UTF-8

Solution 4

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

Share:
33,390
mr.nothing
Author by

mr.nothing

Updated on January 25, 2022

Comments

  • mr.nothing
    mr.nothing about 2 years

    It seems to be really crazy, but I can't do anything with broken encoding in the 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 these done, there is still no luck and symbols are not shown correctly in the console. I tried to debug the 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 has been bothering me for a long time and I was unable to find anything in the web that could help me.