Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAK-40370 - Assignment - UTF-8 problem in grades.csv file #5832

Merged
merged 1 commit into from
Jul 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
SAK-40370 - Assignment - UTF-8 problem in grades.csv file
  • Loading branch information
jesusmmp committed Jul 23, 2018
commit 2708d614e2bb0abc9eb093681af6ce416c459349
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