diff --git a/src/file/csv/CsvReader.php b/src/file/csv/CsvReader.php index b824d20..1e13741 100644 --- a/src/file/csv/CsvReader.php +++ b/src/file/csv/CsvReader.php @@ -9,12 +9,19 @@ class CsvReader extends AbstractReader { function __construct($input, ?array $params=null) { parent::__construct($input, $params); $this->csvFlavour = $params["csv_flavour"] ?? null; + $this->inputEncoding = $params["input_encoding"] ?? null; } protected ?string $csvFlavour; + protected ?string $inputEncoding; + function getIterator() { $reader = new FileReader($this->input); + $inputEncoding = $this->inputEncoding; + if ($inputEncoding !== null) { + $reader->appendFilter("convert.iconv.$inputEncoding.utf-8"); + } $reader->setCsvFlavour($this->csvFlavour); while (($row = $reader->fgetcsv()) !== null) { foreach ($row as &$col) {