Skip to content

Commit 39bb797

Browse files
authored
Merge pull request z-song#5447 from keller31/patch-1
BOM 头应该放到文件头部输出
2 parents a9f9c58 + bc5489e commit 39bb797

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Grid/Exporters/CsvExporter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function export()
160160
$response = function () {
161161
$handle = fopen('php://output', 'w');
162162
$titles = [];
163-
163+
fwrite($handle, chr(0xEF).chr(0xBB).chr(0xBF)); //导出的CSV文件是无BOM编码UTF-8,而我们通常使用UTF-8编码格式都是有BOM的。所以添加BOM于CSV中
164164
$this->chunk(function ($collection) use ($handle, &$titles) {
165165
Column::setOriginalGridModels($collection);
166166

@@ -170,7 +170,7 @@ public function export()
170170
$current = $column->fill($current);
171171
$this->grid->columnNames[] = $column->getName();
172172
});
173-
fwrite($handle, chr(0xEF).chr(0xBB).chr(0xBF)); //导出的CSV文件是无BOM编码UTF-8,而我们通常使用UTF-8编码格式都是有BOM的。所以添加BOM于CSV中
173+
174174
// Write title
175175
if (empty($titles)) {
176176
fputcsv($handle, $titles = $this->getVisiableTitles());

0 commit comments

Comments
 (0)