diff --git a/app/src/processing/app/tools/FixEncoding.java b/app/src/processing/app/tools/FixEncoding.java index ecdfc6df9..e58768ab3 100644 --- a/app/src/processing/app/tools/FixEncoding.java +++ b/app/src/processing/app/tools/FixEncoding.java @@ -3,12 +3,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2008 Ben Fry and Casey Reas + Copyright (c) 2008-11 Ben Fry and Casey Reas This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,8 +23,9 @@ package processing.app.tools; import java.io.BufferedReader; import java.io.File; -import java.io.FileReader; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStreamReader; import javax.swing.JOptionPane; @@ -84,8 +84,18 @@ public class FixEncoding implements Tool { protected String loadWithLocalEncoding(File file) throws IOException { // FileReader uses the default encoding, which is what we want. - FileReader fr = new FileReader(file); - BufferedReader reader = new BufferedReader(fr); + String encoding = System.getProperty("file.encoding"); + if (Base.isMacOS()) { + // Remember that time that Apple decided to change the file encoding + // in later releases of Java? That was really awesome. + if (encoding.equals("UTF-8")) { + // Changing from UTF-8 to UTF-8 isn't going to help much. Argh. + encoding = "MacRoman"; + } + } + FileInputStream fis = new FileInputStream(file); + InputStreamReader isr = new InputStreamReader(fis, encoding); + BufferedReader reader = new BufferedReader(isr); StringBuffer buffer = new StringBuffer(); String line = null; diff --git a/todo.txt b/todo.txt index e770acd00..19343f8ee 100644 --- a/todo.txt +++ b/todo.txt @@ -10,6 +10,7 @@ X http://code.google.com/p/processing/issues/detail?id=466 o occasional exception in "copy for discourse" o http://dev.processing.org/bugs/show_bug.cgi?id=729 X move compiler to mode.java.* instead of runner +X fix the encoding on OS X for the "Fix Encoding and Reload" function fixed in 0192 J auto-format screws up if/else/else if blocks