May 2, 2012

Display UTF-8 text in Eclipse 在 Eclipse 中顯示 UTF-8 文字

If you read text file that encoded with UTF8, Eclipse will show some strange text in Console window.
This is because Eclipse process text encode by MS950 but not for UTF-8.

如果在 Eclipse 讀取 UTF8 的文字檔時,會發現在 Console 視窗顯示亂碼。
這是因為 Eclipse 預設以 MS950 處理文字,而非 UTF-8。

Code Example 範例程式碼:

Step 1. Click Window -> Preferences
步驟一. 點選 Window -> Preferences。

Step 2.Click General -> Workspace then check Text file encoding from Default to Other and select UTF8.
步驟二. 點選  General -> Workspace 將 Text file encoding 從 Default 改成 Other 並選擇 UTF-8。

Step 3. Run the code again, the UTF8 text should display correctly.
步驟三. 重新跑一次程式,就應該能夠正確顯示 UTF8 文字了。

No comments:

Post a Comment