Java tool eclipse console console output garbled problem

After fiddling with it all afternoon, it was finally solved by tm!

Mine is read in by Scanner, and println prints garbled characters.

First, run java in the cmd window, there is no garbled problem, which proves that the code entered by Scanner and printed by println in the cmd window is consistent.

As for eclipse, I have set all the places where utf8 can be set, and verified that the character encoding I entered in the eclispe console is utf-8. Obviously, the problem occurs when outputting to the console.

I also don't know what ghost code is used when eclispe's console output! I used the code to convert the string I entered in various ways, but the problem was not solved, and the cmd window was fine. Obviously, the problem was not in the code, but I didn't know what the hell eclipse did when it was displayed.

The solution is: open the ini of eclipse directly, and add -Dfile.encoding=utf-8 to the last line

It solves the problem of garbled characters that eclipse outputs to the console, and it is also valid for the output of the graphical interface text box.

I haven't figured out what happened, because the cmd window is fine after the change, and I don't know why the console output of eclipse is restricted by -Dfile.encoding=utf-8?

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324900569&siteId=291194637