FriendsOfCake / cakephp-csvview

CakePHP: A view class for generating CSV
MIT License
176 stars 64 forks source link

Got encoding issue with arabic characters #115

Closed w-mazed closed 5 years ago

w-mazed commented 5 years ago

I tried a lot of tricks to solve this issue but I fall, I tried this config: $_extension = 'mbstring'; $_dataEncoding = 'UTF-8'; $_csvEncoding = 'UTF-16LE'; But it solve accentued chars but not arabic chars, any solution for that ?

w-mazed commented 5 years ago

I tried even: $_bom=true; // and passed the variable to the view It still doesn't work.

saeideng commented 5 years ago

this works for me this creates with utf-8 character set

  public function export()
{
      $data = [
        ['a', 'b', 'c'],
        [1, 2, 3],
        ['سلام', 'العربية', 'me'],
    ];
    $_serialize = 'data';
    $this->viewBuilder()->setClassName('CsvView.Csv');
    $this->set(compact('data', '_serialize'));
}
ADmad commented 5 years ago

I tried a lot of tricks to solve this issue but I fall,

You don't need any tricks. Just make sure the file encoding for your PHP files and your database tables / columns (and encoding in connection config) is set to UTF-8.

w-mazed commented 5 years ago

@ADmad thank you for your answer but indeed, datase, tables and columns all are encoded in UTF-8.

I used https://github.com/thephpleague/csv and it works fine after Setting the outputted BOM sequence (BTW I tried with $_bom=true; and it didn't work). So may be the problem is there.

ADmad commented 5 years ago

Only you can debug and figure out what the problem is. If you stumble upon a bug you can provide details to reproduce or a fix for it.