最簡單方法解決RCP程序UTF-8編碼問題

方案一:

網上流傳的經典方案,但是說明的不是很詳細,這裏補充一下:

在eclipse rcp 使用utf-8編碼,調試運行都正常,在導出後運行出現中文亂碼問題, 查詢資料後作如下調整得以解決

1>打開plugin.xml,選擇build頁面,選中"Custom Build"複選框

2> 右鍵單擊build.properites文件,PDE tools --> Create Ant Build File

3>修改build.xml文件,添加javac參數encoding="UTF-8"

 

補充: 


  1. 找到如下標籤: 
  2. <!-- compile the source code --> 
  3.         <javac destdir="${build.result.folder}/@dot" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}"  > 
  4.  
  5. 修改爲: 
  6. <!-- compile the source code --> 
  7.         <javac destdir="${build.result.folder}/@dot" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}" encoding="UTF-8" > 

4>重新導出工程,能正確顯示中文

OK!

 

方案二,直接在build.properties視圖下添加一行:

 

  1. javacDefaultEncoding.. = UTF-8 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章