FriendsOfCake/cakephp-csvview

Got encoding issue with arabic characters

w-mazed opened this issue · 5 comments

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 ?

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

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

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.

@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

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.