Update Csv.php
Add "outputEncoding" property. "outputEncoding" property is used by mb_convert_encoding function.
This commit is contained in:
parent
1318b90330
commit
0bb625bc68
|
|
@ -64,6 +64,13 @@ class Csv extends BaseWriter
|
||||||
*/
|
*/
|
||||||
private $excelCompatibility = false;
|
private $excelCompatibility = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output encoding.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $outputEncoding = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new CSV.
|
* Create a new CSV.
|
||||||
*
|
*
|
||||||
|
|
@ -296,6 +303,30 @@ class Csv extends BaseWriter
|
||||||
return $this;
|
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;
|
private $enclosureRequired = true;
|
||||||
|
|
||||||
public function setEnclosureRequired(bool $value): self
|
public function setEnclosureRequired(bool $value): self
|
||||||
|
|
@ -347,6 +378,9 @@ class Csv extends BaseWriter
|
||||||
$line .= $this->lineEnding;
|
$line .= $this->lineEnding;
|
||||||
|
|
||||||
// Write to file
|
// Write to file
|
||||||
|
if ($this->outputEncoding != '') {
|
||||||
|
$line = mb_convert_encoding($line, $this->outputEncoding);
|
||||||
|
}
|
||||||
fwrite($pFileHandle, $line);
|
fwrite($pFileHandle, $line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue