vitorccs / laravel-csv

PHP Laravel package to export and import CSV files in a memory-optimized way
MIT License
26 stars 5 forks source link

Set bom. #3

Closed luckydonald closed 1 year ago

luckydonald commented 1 year ago

I need to set the UTF-8 BOM, for example as seen in the league/csv docs

$csv->setOutputBOM(Reader::BOM_UTF8);

Can I somehow get hold of that $csv add that somewhere?

Edit: If I read correctly this isn't even using league/csv, so that doesn't really helps.

But in my case I just would need to prepend $utf8_bom = "\xEF\xBB\xBF"; (the BOM for UTF-8) to the returned CSV.

vitorccs commented 1 year ago

@luckydonald The UT8 BOM is enabled by default in the config file: https://github.com/vitorccs/laravel-csv/blob/master/config/csv.php#L36

Here you can see it is being generated: https://github.com/vitorccs/laravel-csv/blob/master/src/Handlers/StreamHandler.php#L59

https://github.com/vitorccs/laravel-csv/blob/master/src/Helpers/CsvHelper.php#L30

luckydonald commented 1 year ago

I get the feeling the boom itself should be configurable once you need UTF-16, etc. However not in my case, utf-8 works fine here.


Btw, best to use permanent links (by pressing y when having the file open). Also it gives neat previews:

Permalinks for the links above:

vitorccs commented 1 year ago

@luckydonald thanks for the tip. I am closing the issue.