consume Unicode BOM (0xFEFF) in createReader() and Table parser

This commit is contained in:
Ben Fry
2017-01-30 19:23:02 -05:00
parent da04e3682f
commit ea65d7f034
3 changed files with 29 additions and 2 deletions

View File

@@ -378,6 +378,15 @@ public class Table {
} else {
InputStreamReader isr = new InputStreamReader(input, encoding);
BufferedReader reader = new BufferedReader(isr);
// strip out the Unicode BOM, if present
reader.mark(1);
int c = reader.read();
// if not the BOM, back up to the beginning again
if (c != '\uFEFF') {
reader.reset();
}
/*
if (awfulCSV) {
parseAwfulCSV(reader, header);
@@ -4039,6 +4048,7 @@ public class Table {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/**
* @webref table:method
* @brief Trims whitespace from values