Skip to content

Commit 5037623

Browse files
authored
Merge pull request #13 from loekvangool/patch-1
Add UTF8 support
2 parents e48573b + 2cd2fee commit 5037623

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/File/Json.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class Json extends AbstractFile
1616
'enclosure' => '"',
1717
'escape' => '\\',
1818
'join' => '_',
19-
'null' => null
19+
'null' => null,
20+
'utf8_encoding' => false
2021
];
2122

2223
/**
@@ -43,6 +44,9 @@ public function convert(): string
4344
protected function toCsvString(array $data): string
4445
{
4546
$f = fopen('php://temp', 'wb');
47+
if($this->conversion["utf8_encoding"]) {
48+
fprintf($f, chr(0xEF).chr(0xBB).chr(0xBF));
49+
}
4650
$this->putCsv($f, array_keys(current($data)));
4751
array_walk($data, function ($row) use (&$f) {
4852
$this->putCsv($f, $row);

0 commit comments

Comments
 (0)