Update Csv.php

Add "outputEncoding" property.
"outputEncoding" property is used by mb_convert_encoding function.
This commit is contained in:
Akira Taniguchi 2021-02-21 11:36:37 +09:00 committed by GitHub
parent 1318b90330
commit 0bb625bc68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 0 deletions

View File

@ -64,6 +64,13 @@ class Csv extends BaseWriter
*/
private $excelCompatibility = false;
/**
* Output encoding.
*
* @var string
*/
private $outputEncoding = '';
/**
* Create a new CSV.
*
@ -296,6 +303,30 @@ class Csv extends BaseWriter
return $this;
}
/**
* Get output encoding.
*
* @return string
*/
public function getOutputEncoding()
{
return $this->outputEncoding;
}
/**
* Set output encoding.
*
* @param string $pValue Output encoding
*
* @return $this
*/
public function setOutputEncoding($pValue)
{
$this->outputEncoding = $pValue;
return $this;
}
private $enclosureRequired = true;
public function setEnclosureRequired(bool $value): self
@ -347,6 +378,9 @@ class Csv extends BaseWriter
$line .= $this->lineEnding;
// Write to file
if ($this->outputEncoding != '') {
$line = mb_convert_encoding($line, $this->outputEncoding);
}
fwrite($pFileHandle, $line);
}
}