トラブル:EclipseでUTF-8のパッチを開くと文字化けする
現象
Eclipseでプロジェクトを右クリック -> Team -> Apply Patch... -> File して以下のUTF-8のパッチを開くと文字化けする:
diff --git a/hoge.txt b/hoge.txt new file mode 100644 index 0000000..0005c4e --- /dev/null +++ b/hoge.txt @@ -0,0 +1 @@ +あいうえお
原因
Apply Patchがパッチをシステムプロパティのfile.encodingの値で開く。
かつfile.encoding=MS932になっている:
参考文献
- Bug 421084 - Patches in UTF-8 get applied with the platform encoding, https://bugs.eclipse.org/bugs/show_bug.cgi?id=421084
- Bug 404713 - "Create Patch" creates patch in UTF-8 (without BOM) irrespective of the file encoding (Windows-1252), https://bugs.eclipse.org/bugs/show_bug.cgi?id=404713