2016-02-05 85 views
8

这似乎是非常疯狂,但我无法做任何与intellij想法控制台中的破损编码。Intellij想法在控制台输出不正确的编码

事情我做了解决此问题:

  1. 设置-Dfile.encoding = UTF-8和-Dfile.encoding = UTF-8将在idea.exe.vmoptions和idea64.exe.vmoptions(我尽管使用64位版本)。
  2. 增加了-Dfile.encoding = UTF-8和-Dfile.encoding = UTF-8来运行/调试我的应用程序的配置。
  3. 更改设置>编辑器>文件编码属性文件的IDE编码/项目编码/默认编码为UTF-8。

说完这一切后,仍然没有运气和符号不会在控制台正确显示。我试图调试java.io.PrintStream#println(java.lang.String)方法,发现System.out.textOut.out.se.cs等于windows-1251。不知道这个值来自哪里。

这个问题一直困扰我很长一段时间,我无法找到任何可以帮助我的网络。

在此先感谢您的帮助。

+0

请提供一些代码:http://stackoverflow.com/help/mcve –

+0

'System.out.println(“\ u0394”);'打印[Greek Character Delta](http://unicode-table.com/en/0394 /),Δ。这是什么打印给你? –

+0

@JakeHendy对不起,延迟回答。 'System.out.println(“\ u0394”);''是'?'的结果。 –

回答

4

尝试

-Dconsole.encoding=UTF-8 

,而不是

-Dfile.encoding=UTF-8 
+0

谢谢!这奏效了我。 – Chris

+0

它工作在tomcat的虚拟机选项。谢谢! – traeper

2

我的理论是,你的Java类文件正在使用 “窗口 - 1251” 编码,你需要设置 “UTF-8”。

看下面的截图。 enter image description here enter image description here

要重置所有文件编码,您可以手动编辑encodings.xml。 enter image description here 您可以在设置对话框中更改默认文件编码。 enter image description here

+0

谢谢您的输入,但我的问题是有点不同。 –

0

在我的情况在调试检查System.out.textOut.out.se.cs暗示IDEA picked up maven surefire arguments每一个JUnit的运行配置:

<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> 

我已经加入到-Didea.maven.surefire.disable.argLine=true文件idea64.exe.vmoptions解决了这个。请参阅https://www.jetbrains.com/help/idea/configuring-output-encoding.html