Remember that time that Apple decided to change the file encoding? That was awesome.

This commit is contained in:
benfry
2011-01-30 00:09:52 +00:00
parent 8d4e8069f9
commit 1bfb1759c8
2 changed files with 17 additions and 6 deletions
+16 -6
View File
@@ -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;
+1
View File
@@ -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