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

chinese GBK make me trouble #56

Closed
mengdodo opened this issue Sep 15, 2018 · 4 comments
Closed

chinese GBK make me trouble #56

mengdodo opened this issue Sep 15, 2018 · 4 comments

Comments

@mengdodo
Copy link

detail:
b"ÉÌÆ·Ãû³Æ" => b"»ªÎªÈÙÒ«9¸Ö»¯Ä¤v10v9ÈÙÒ«8Çà´º°ænova2sÈ«ÆÁplay¸²¸Ç9iÌùĤmate°Ëp20proÊÖ»úp9p10Ô­×°v8¾Åplus¿¹À¶¹âÈ«°ü±ß"

please help me.....

my code:
$path = storage_path('app/uploads/3.csv');
(new FastExcel)->import($path, function ($line) {
dd($line);
});

@mengdodo
Copy link
Author

mengdodo commented Sep 15, 2018

i have solved this problem.

edit FastExcel.php file

public function __construct($data = null)
{
    $this->data = $data;
    $this->csv_configuration['encoding'] = $data['encoding'];
}

next, in laravel controller

(new FastExcel(['encoding' => 'gbk']))->import($path, function ($line) {
dd($line);
});

@Pochwar
Copy link
Contributor

Pochwar commented Oct 2, 2018

@mengdodo
Hi, nice if you solve your issue!

By the way, there is a configureCsv() method in fast-excel that allows you to do this properly.
Here's an example:

$path = storage_path('app/uploads/3.csv');
(new FastExcel)->configureCsv(',', '"', '\n', 'gbk')->import($path, function ($line) {
    dd($line);
});

As encoding is the fourth argument of this method, you have to define the tree other before: delimiter, enclosure and eol.

@rap2hpoutre
Copy link
Owner

Thanks @Pochwar !
@mengdodo Did it solve your issue?

@mengdodo
Copy link
Author

mengdodo commented Oct 5, 2018

@rap2hpoutre @Pochwar thanks ,I have solved this problem

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

No branches or pull requests

3 participants