diff --git a/src/Encoder/CsvEncoder.php b/src/Encoder/CsvEncoder.php index 93701d3..813d431 100644 --- a/src/Encoder/CsvEncoder.php +++ b/src/Encoder/CsvEncoder.php @@ -68,13 +68,6 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { protected $useUtf8Bom = FALSE; /** - * Determine output encoding. - * - * @var string - */ - protected $encoding = 'utf-8'; - - /** * Constructs the class. * * @param string $delimiter @@ -145,14 +138,6 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { $csv->setEnclosure($this->enclosure); $csv->setEscape($this->escapeChar); - // Convert charset. - if ($this->encoding != 'utf-8') { - $encoder = (new CharsetConverter()) - ->inputEncoding('utf-8') - ->outputEncoding('iso-8859-15'); - $csv->addFormatter($encoder); - } - // Set data. if ($this->useUtf8Bom) { $csv->setOutputBOM(ByteSequence::BOM_UTF8); @@ -265,7 +250,6 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { * * @return string * The formatted value. - * */ protected function formatValue($value) { if ($this->stripTags) { @@ -337,7 +321,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { protected function arrayDepth($array) { $max_indentation = 1; - $array_str = print_r($array, true); + $array_str = print_r($array, TRUE); $lines = explode("\n", $array_str); foreach ($lines as $line) { @@ -354,21 +338,26 @@ class CsvEncoder implements EncoderInterface, DecoderInterface { /** * Set CSV settings from the Views settings array. * + * This allows modules which provides integration + * (views_data_export for example) to change default settings. + * * If a tab character ('\t') is used for the delimiter, it will be properly * converted to "\t". * * @param array $settings * Array of settings. + * + * @see \Drupal\views_data_export\Plugin\views\style\DataExport() + * for list of settings. */ protected function setSettings(array $settings) { // Replace tab character with one that will be properly interpreted. $this->delimiter = str_replace('\t', "\t", $settings['delimiter']); $this->enclosure = $settings['enclosure']; $this->escapeChar = $settings['escape_char']; - $this->useUtf8Bom = ($settings['encoding'] === 'utf-8' && !empty($settings['utf8_bom'])); + $this->useUtf8Bom = ($settings['encoding'] === 'utf8' && !empty($settings['utf8_bom'])); $this->stripTags = $settings['strip_tags']; $this->trimValues = $settings['trim']; - $this->encoding = $settings['encoding']; } }