Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utf8 bom for ms excel #34

Merged
merged 4 commits into from
Oct 21, 2016
Merged

Conversation

itcrab
Copy link

@itcrab itcrab commented Apr 4, 2016

Hi, Jonathan!

In one of my project I have a problem with cyrillic symbols in generated CSV-file.

We have simple source:

require_once __DIR__ . '/vendor/autoload.php';

$writer = new \EasyCSV\Writer('write.csv');
$writer->writeFromArray(array(
    'колонка 1, колонка 2, колонка 3',
    array('значение 1', 'значение 2', 'значение 3')
));

And when we open it CSV-file in MS Excel take this:
image

For solve this problem I do this PR. Now you may set flag $isNeedBOM for give know Writer to insert UTF-8 BOM symbol in start CSV-file. When you do reading this CSV-file we checks exists UTF-8 BOM symbol and if it true - remove from first line.

Some source:

$writer = new \EasyCSV\Writer('write.csv', 'r+', true);
$writer->writeFromArray(array(
    'колонка 1, колонка 2, колонка 3',
    array('значение 1', 'значение 2', 'значение 3')
));

Give us good result on MS Excel:
image

I add small tests for this PR and if you see any more tests I will be add its.

@itcrab
Copy link
Author

itcrab commented Apr 9, 2016

@jwage ping

@sharipoutra5
Copy link

I agree and I want to learn more

@itcrab
Copy link
Author

itcrab commented May 1, 2016

@jwage ping

1 similar comment
@itcrab
Copy link
Author

itcrab commented Jun 6, 2016

@jwage ping

@simwodb1
Copy link

good

@itcrab
Copy link
Author

itcrab commented Aug 21, 2016

@jwage ping

@itcrab
Copy link
Author

itcrab commented Aug 21, 2016

@jwage you may merge my pull request?

@jwage
Copy link
Owner

jwage commented Oct 21, 2016

👍 sorry for the delay.

@jwage jwage merged commit 352781c into jwage:master Oct 21, 2016
@hussain2022a
Copy link

Hussain @ #

@hussain2022a hussain2022a mentioned this pull request Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants