Skip to content

Commit

Permalink
SAK-40370 - Assignment - UTF-8 problem in grades.csv file (sakaiproje…
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusmmp authored and juanjmerono committed Jul 23, 2018
1 parent ce9a3a4 commit 13e3192
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
Expand Down Expand Up @@ -92,10 +93,17 @@ class CsvExporter extends SpreadsheetExporter {

private final ByteArrayOutputStream gradesBAOS;
private final CSVWriter gradesBuffer;
private static final String BOM = "\uFEFF";

CsvExporter(String title, String gradeType, String csvSep) {
gradesBAOS = new ByteArrayOutputStream();
gradesBuffer = new CSVWriter(new OutputStreamWriter(gradesBAOS), csvSep.charAt(0));
OutputStreamWriter osw = new OutputStreamWriter(gradesBAOS, Charset.forName("UTF-8"));
try {
osw.write(BOM);
} catch (IOException e) {
// tried
}
gradesBuffer = new CSVWriter(osw, csvSep.charAt(0));
addRow(title, gradeType);
addRow("");
}
Expand Down

0 comments on commit 13e3192

Please sign in to comment.