Be sure to use UTF-8 when saving data.txt, pool.txt, and change files.

Fix issue 163: Refine doesn't retain the characters for flat or sharp.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1588 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-10-17 23:43:02 +00:00
parent a9a3944cbf
commit c8dcc10ab8
4 changed files with 20 additions and 14 deletions

View File

@ -31,7 +31,7 @@ import com.google.refine.util.Pool;
*/
public class History implements Jsonizable {
static public Change readOneChange(InputStream in, Pool pool) throws Exception {
LineNumberReader reader = new LineNumberReader(new InputStreamReader(in));
LineNumberReader reader = new LineNumberReader(new InputStreamReader(in, "UTF-8"));
try {
return readOneChange(reader, pool);
} finally {
@ -51,7 +51,7 @@ public class History implements Jsonizable {
}
static public void writeOneChange(OutputStream out, Change change, Pool pool) throws IOException {
Writer writer = new OutputStreamWriter(out);
Writer writer = new OutputStreamWriter(out, "UTF-8");
try {
History.writeOneChange(writer, change, pool);
} finally {

View File

@ -2,8 +2,6 @@ package com.google.refine.io;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
@ -115,15 +113,11 @@ public class ProjectUtilities {
Pool pool = new Pool();
ZipEntry poolEntry = zipFile.getEntry("pool.txt");
if (poolEntry != null) {
pool.load(new InputStreamReader(
zipFile.getInputStream(poolEntry)));
pool.load(zipFile.getInputStream(poolEntry));
} // else, it's a legacy project file
return Project.loadFromReader(
new LineNumberReader(
new InputStreamReader(
zipFile.getInputStream(
zipFile.getEntry("data.txt")))),
return Project.loadFromInputStream(
zipFile.getInputStream(zipFile.getEntry("data.txt")),
id,
pool
);

View File

@ -1,6 +1,8 @@
package com.google.refine.model;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
@ -96,7 +98,7 @@ public class Project {
}
}
Writer writer = new OutputStreamWriter(out);
Writer writer = new OutputStreamWriter(out, "UTF-8");
try {
Properties options = new Properties();
options.setProperty("mode", "save");
@ -143,7 +145,11 @@ public class Project {
}
}
static public Project loadFromReader(
static public Project loadFromInputStream(InputStream is, long id, Pool pool) throws Exception {
return loadFromReader(new LineNumberReader(new InputStreamReader(is, "UTF-8")), id, pool);
}
static private Project loadFromReader(
LineNumberReader reader,
long id,
Pool pool

View File

@ -1,6 +1,8 @@
package com.google.refine.util;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
@ -53,7 +55,7 @@ public class Pool implements Jsonizable {
}
public void save(OutputStream out) throws IOException {
Writer writer = new OutputStreamWriter(out);
Writer writer = new OutputStreamWriter(out, "UTF-8");
try {
save(writer);
} finally {
@ -97,6 +99,10 @@ public class Pool implements Jsonizable {
}
}
public void load(InputStream is) throws Exception {
load(new InputStreamReader(is, "UTF-8"));
}
public void load(Reader reader) throws Exception {
LineNumberReader reader2 = new LineNumberReader(reader);