2013年10月2日 星期三

Eclipse console input 中文 問題

http://rritw.com/a/caozuoxitong/20120624/175594.html
文章1: 
安裝了Myeclipse 9之後,web應用程序,tomcat控制台亂碼 
按照網上的方法 
1.Windows->Preferences->general->Workspace->Text file encoding->Other框中的Text file encoding改为UTF-8。 
2.Windows->Preferences->General->Editors->TextEditors->Spelling Encoding 改为UTF-8 
3.Servers窗口中,tomcat服務器右擊->runconfiguration->common->encoding 設置为UTF-8 
全都設置了之後,consolen中的中文依舊顯示为“” 
折騰了好久都沒有得到解决。 
後來考慮到,我的操作系統是英文版的,猜想與操作系統有關,在網上搜索之後終於找到了。 
打開Control Panel->Clock,Language,and Region->Region and Language->Format選項卡,Format選擇相應的語言,之後重启myeclipse就好了。 


文章2: 

這真是個很討厭的問題 

當我所有的設定都設成UTF-8的時候 

偏偏console怎麼搞都是亂碼 



後來才發現當java檔編碼設為BIG5時就正常了… 

這不是我要的! 



再後來發現這篇 

Eclipse 執行時如何讓Console顯示中文 

Eclipse主功能表-->Run-->Run Configuration-->Common 頁籤--> 

Console Encoding-->Others-->big5 (沒有就手動輸入)-->Apply 



最後是印出正常的中文,但是這代表JDK應該是自己把它變成BIG5 

所以導至設定成UTF-8的Console會印出亂碼! 



建置全UTF-8的環境: 

1.在eclipse.ini的-vmargs下面加上「-Dfile.encoding=UTF-8」。 

2.eclipse-->Window-->Preferences-->General-->Workspace-->Text file encoding-->UTF-8 

3.Installed JREs-->Default VM Arguments:-->-Dfile.encoding=UTF-8 

4.eclipse-->Run-->Run Configurations-->Arguments-->VM arguments-->-Dfile.encoding=UTF-8 

5.eclipse-->Run-->Run Configuration-->Common 頁籤--> Console Encoding-->Others-->UTF-8 

==>亂碼! 

5.eclipse-->Run-->Run Configuration-->Common 頁籤--> Console Encoding-->Others-->big5 

==>ok! 




目前發現是 JDK的問題: 

a.若是用JDK1.4那console得設定成big5才行! 

b.若是用JDK6,那用UTF-8就沒問題! 




eclipse.ini的-vmargs下面加上「-Dfile.encoding=UTF-8」eclipse 的默認編碼,當設置英文操作系統的語言環境为中文簡體是,其默認为GBK