2016-02-05 87 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