Index: /other-projects/UTF8-Fix/.classpath
===================================================================
--- /other-projects/UTF8-Fix/.classpath	(revision 32225)
+++ /other-projects/UTF8-Fix/.classpath	(revision 32225)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: /other-projects/UTF8-Fix/.project
===================================================================
--- /other-projects/UTF8-Fix/.project	(revision 32225)
+++ /other-projects/UTF8-Fix/.project	(revision 32225)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>UTF8_Fix</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: /other-projects/UTF8-Fix/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- /other-projects/UTF8-Fix/.settings/org.eclipse.jdt.core.prefs	(revision 32225)
+++ /other-projects/UTF8-Fix/.settings/org.eclipse.jdt.core.prefs	(revision 32225)
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
Index: /other-projects/UTF8-Fix/smallBad.txt
===================================================================
--- /other-projects/UTF8-Fix/smallBad.txt	(revision 32225)
+++ /other-projects/UTF8-Fix/smallBad.txt	(revision 32225)
@@ -0,0 +1,10 @@
+  </datafield>
+  <datafield tag="245" ind1="0" ind2="0">
+    <subfield code="a">Australien, Californien, Mexiko /</subfield>
+    <subfield code="c">Reisebilder von Madame Giovanni ; geordnet und herausgegeben von Alexander Dumas ; nach dem franzèosischen Manuscripte von G.F.W. Rèodiger.</subfield>
+  </datafield>
+  <datafield tag="250" ind1=" " ind2=" ">
+    <subfield code="a">Autorisirte Ausg.</subfield>
+  </datafield>
+  <datafield tag="260" ind1=" " ind2=" ">
+    <subfield code="a">Pest :</subfield>
Index: /other-projects/UTF8-Fix/src/ByteFixer.java
===================================================================
--- /other-projects/UTF8-Fix/src/ByteFixer.java	(revision 32225)
+++ /other-projects/UTF8-Fix/src/ByteFixer.java	(revision 32225)
@@ -0,0 +1,130 @@
+import java.io.*;
+import java.util.ArrayList;
+
+
+public class ByteFixer {
+	private File fin ;
+	private ArrayList<Byte> Queue;
+	private byte[] OverrunByte;
+	private DataInputStream reader;
+	public ByteFixer(String FileName)	{
+		Queue = new ArrayList<Byte>();
+		fin = new File(FileName);
+		try{
+			reader = new DataInputStream(new FileInputStream(fin));
+		} catch(FileNotFoundException e){
+			System.err.println("Input file not found");
+			return;
+		}
+	}
+
+	public void close(){
+		try {
+			reader.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	public void fixCharacter() throws UnsupportedEncodingException{
+		
+		boolean done_ansel_quick_fix = false;
+		
+		
+		if (Queue.size() == 1) {
+			byte first_char = Queue.get(0);
+			if (first_char == 0xB0) {
+				done_ansel_quick_fix = true;
+				Queue.set(0,(byte)'`');
+			}
+			else if (first_char == 0xFE) {
+				done_ansel_quick_fix = true;
+				Queue.set(0,(byte)'\'');
+			}
+		}
+
+		if (done_ansel_quick_fix) {
+			return;
+		}
+		
+		//Copy Queue to byte array
+		byte[] Character = new byte[Queue.size()];
+		for(int i=0; i < Queue.size(); i++)
+			Character[i]=Queue.get(i);
+		
+		//Convert to ISO8859 
+		String str = new String(Character,"ISO-8859-1");
+		
+		byte[] UTF8 = str.getBytes("UTF-8");
+		
+		System.err.println("FIXED TO: " + new String(UTF8, "UTF-8"));
+		
+		Queue = new ArrayList<Byte>();
+		for(int i=0; i < UTF8.length; i++)
+			Queue.add(UTF8[i]);
+		return;
+	}
+	
+	public byte[] getNextCharacter(){
+		
+		int head;
+		
+		if(OverrunByte!=null){
+			byte[] Queue_Bytes = new byte[1];
+			Queue_Bytes[0] = OverrunByte[0];
+			OverrunByte = null;
+			return Queue_Bytes;
+		}
+		
+		try{
+			 head = reader.readUnsignedByte();
+			 if((head & 0x80)==0){
+				 //Simple ASCII case, 1-byte sequence
+				 Queue.add((byte)head);
+			 }
+			 else{
+				 //If >1-byte sequence
+				 
+				 Queue.add((byte)head);
+				 
+				 if ((head & 0xC0) != 0xC0) {
+					 // Isn't the start of a valid UTF-8 sequence
+					 fixCharacter();
+				 }
+				 else {
+					 head = head << 1;
+					 while((head & 0x80)!=0){
+						 int next = reader.readUnsignedByte();
+						 if((next & 0xC0)==0x80)
+							 Queue.add((byte)next);
+						 else{
+							 //If sequence end
+							 String s = Integer.toBinaryString(next);
+							 System.err.println("Encountered non-UTF8 character " + s);
+							 //Convert to UTF8
+							 fixCharacter();
+							 //Save overrun byte
+							 OverrunByte = new byte[1];
+							 OverrunByte[0] = (byte)next;
+							 break;
+						 }
+						 head = head << 1;
+					 }
+				 }
+			 }
+		}catch(EOFException e){
+			System.out.println("End of file reached");
+			return null;
+		}catch(Exception e){
+			e.printStackTrace();
+		}
+		//Copy Queue to byte array
+		byte[] Queue_Bytes = new byte[Queue.size()];
+		for(int i=0; i < Queue.size(); i++){
+			Queue_Bytes[i] = Queue.get(i);
+		}
+		//Reset queue to be empty
+		Queue = new ArrayList<Byte>();
+		return Queue_Bytes;
+	}
+	
+}
Index: /other-projects/UTF8-Fix/src/UTF8Fix.java
===================================================================
--- /other-projects/UTF8-Fix/src/UTF8Fix.java	(revision 32225)
+++ /other-projects/UTF8-Fix/src/UTF8Fix.java	(revision 32225)
@@ -0,0 +1,49 @@
+import java.io.*;
+
+
+public class UTF8Fix{
+	
+	public static void main(String[] args){
+
+		ByteFixer byte_fixer = new ByteFixer("badencoding.txt");
+		File fout = new File("goodencoding.txt");
+		BufferedOutputStream writer = null;
+		
+		try {
+			writer = new BufferedOutputStream(new FileOutputStream(fout));
+		} catch (FileNotFoundException e) {
+			System.err.println("Problem opening writer, file not found");
+			return;
+		}
+				
+		byte[] character;
+		int count = 0;
+		while(true){
+			character = byte_fixer.getNextCharacter();
+			if(character==null)
+				break;
+			
+			try {
+				writer.write(character);
+				count++;
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			
+			if(count%1000==0){
+				System.out.print(".");
+				System.out.flush();
+				if(count==40000){
+					System.out.println();
+					count=0;
+				}
+			}
+		}
+		try {
+			byte_fixer.close();
+			writer.close();
+		} catch (IOException e) {
+			System.err.println("Unable to close reader/writer");
+		}		
+	}
+}
