From b4e85cbbd353fae4ea5ab5f74ff845b36dfd2962 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Thu, 12 May 2016 07:41:44 -0400 Subject: [PATCH] implement support for encoding= option in loadTable() --- core/src/processing/data/Table.java | 6 +++++- core/todo.txt | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index 72055921b..dd93f8a99 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -331,6 +331,7 @@ public class Table { boolean header = false; String extension = null; boolean binary = false; + String encoding = "UTF-8"; String worksheet = null; final String sheetParam = "worksheet="; @@ -357,6 +358,8 @@ public class Table { worksheet = opt.substring(sheetParam.length()); } else if (opt.startsWith("dictionary=")) { // ignore option, this is only handled by PApplet + } else if (opt.startsWith("encoding=")) { + encoding = opt.substring(9); } else { throw new IllegalArgumentException("'" + opt + "' is not a valid option for loading a Table"); } @@ -374,7 +377,8 @@ public class Table { odsParse(input, worksheet, header); } else { - BufferedReader reader = PApplet.createReader(input); + InputStreamReader isr = new InputStreamReader(input, encoding); + BufferedReader reader = new BufferedReader(isr); if (awfulCSV) { parseAwfulCSV(reader, header); } else if ("tsv".equals(extension)) { diff --git a/core/todo.txt b/core/todo.txt index 01cdde701..4c62129bb 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,4 +1,5 @@ 0250 (3.1.1) +X implement support for encoding= option in loadTable() jakub X Block loadImage and requestImage while images still being saved